From 672c115beba5a2781e4a1d9a130d41842c2950a1 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 2 Mar 2025 01:40:33 +0000 Subject: [PATCH 01/12] Better type lookup in supertrait walking --- c-bindings-gen/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index 2dd5c81e..09404855 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -1067,10 +1067,11 @@ fn writeln_impl(w: &mut W, w_uses: &mut HashSet { if let Some(supertrait) = types.crate_types.traits.get(s) { supertrait_name = s.to_string(); @@ -1193,7 +1194,7 @@ fn writeln_impl(w: &mut W, w_uses: &mut HashSet { requires_clone = true; writeln!(w, "\t\tcloned: Some({}_{}_cloned),", trait_obj.ident, ident).unwrap(); From 50ee279fd3a3cab9c05feb81a00b4f63238add2b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 2 Mar 2025 01:41:39 +0000 Subject: [PATCH 02/12] Ensure we create full directories we need for output --- c-bindings-gen/src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index 09404855..d78289a2 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -2170,7 +2170,19 @@ fn convert_file<'a, 'b>(libast: &'a FullLibraryAST, crate_types: &CrateTypes<'a> } else { format!("{}/lib.rs", out_dir) }; - let _ = std::fs::create_dir((&new_file_path.as_ref() as &std::path::Path).parent().unwrap()); + + fn create_dir_recursive(path: &std::path::Path) { + match std::fs::create_dir(path) { + Ok(_) => {}, + Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {}, + Err(_) => { + create_dir_recursive(path.parent().unwrap()); + std::fs::create_dir(path).expect("Failed to create output dir"); + }, + } + } + create_dir_recursive((&new_file_path.as_ref() as &std::path::Path).parent().unwrap()); + let mut out = std::fs::OpenOptions::new().write(true).create(true).truncate(true) .open(new_file_path).expect("Unable to open new src file"); let mut out_uses = HashSet::default(); From 4c104127ba1b8e8b75dc4c2e99e9fd806ed7fada Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 4 Jun 2024 22:06:42 +0000 Subject: [PATCH 03/12] Don't pass 'embed-bitcode'/'lto' while building proc-macros cargo is usually good about not passing `RUSTFLAGS` to build-time dependencies which need to be built for the host platform rather than the target platform, but for some reason it does not do so for `proc-macro` crates. Thus, we have to manually drop the `embed-bitcode` and `lto` arguments when calling rustc in our existing rustc wrapper. --- deterministic-build-wrappers/rustc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/deterministic-build-wrappers/rustc b/deterministic-build-wrappers/rustc index 5ac8fe21..e8983fd0 100755 --- a/deterministic-build-wrappers/rustc +++ b/deterministic-build-wrappers/rustc @@ -7,13 +7,21 @@ # ever (indirectly) depend on multiple versions of the same crate. args=("$@") IS_LIGHTNING=false +SKIP_EMBED_BITCODE=false for ((i=0; i<"${#args[@]}"; ++i)); do case ${args[i]} in --crate-name) - if [ "${args[i+1]}" = "lightning" -o "${args[i+1]}" = "lightning_types" -o "${args[i+1]}" = "lightning_background_processor" -o "${args[i+1]}" = "lightning_invoice" -o "${args[i+1]}" = "lightning_persister" -o "${args[i+1]}" = "lightning_rapid_gossip_sync" -o "${args[i+1]}" = "ldk" ]; then + if [ "${args[i+1]}" = "lightning" -o "${args[i+1]}" = "lightning_types" -o "${args[i+1]}" = "lightning_background_processor" -o "${args[i+1]}" = "lightning_invoice" -o "${args[i+1]}" = "lightning_persister" -o "${args[i+1]}" = "lightning_rapid_gossip_sync" -o "${args[i+1]}" = "lightning_transaction_sync" -o "${args[i+1]}" = "ldk" ]; then IS_LIGHTNING=true fi ;; + --crate-type) + if [ "${args[i+1]}" = "proc-macro" ]; then + # If we're building a proc-macro, rustc incorrectly passes our RUSTFLAGS containing + # embed-bitcode=yes, which we don't want. + SKIP_EMBED_BITCODE=true + fi + ;; esac done for ((i=0; i<"${#args[@]}"; ++i)); do @@ -24,7 +32,16 @@ for ((i=0; i<"${#args[@]}"; ++i)); do args[i]="metadata=42" fi ;; + embed-bitcode=yes) + if [ "$SKIP_EMBED_BITCODE" = "true" ]; then + args[i]="embed-bitcode=no" + fi + ;; + lto) + if [ "$SKIP_EMBED_BITCODE" = "true" ]; then + args[i]="lto=no" + fi + ;; esac done - $LDK_RUSTC_PATH "${args[@]}" From ad26d98304fc90080ee332545280f047c50ec630 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 4 Apr 2025 18:28:44 +0000 Subject: [PATCH 04/12] Map `bitcoin::Address` via a type rather than a string ...allowing users to build an `Address` safely. --- c-bindings-gen/src/types.rs | 11 +++++-- genbindings.sh | 3 ++ lightning-c-bindings/src/c_types/mod.rs | 43 ++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index fa9cd05a..5ac95570 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -1076,7 +1076,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "str" => Some("crate::c_types::Str"), "alloc::string::String"|"String"|"std::path::PathBuf" => Some("crate::c_types::Str"), - "bitcoin::address::Address"|"bitcoin::Address" => Some("crate::c_types::Str"), + "bitcoin::address::Address"|"bitcoin::Address" => Some("crate::c_types::Address"), "std::time::Duration"|"core::time::Duration" => Some("u64"), "std::time::SystemTime" => Some("u64"), @@ -1206,6 +1206,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "core::num::ParseIntError" => Some("u8::from_str_radix(\" a\", 10).unwrap_err() /*"), "core::str::Utf8Error" => Some("core::str::from_utf8(&[0xff]).unwrap_err() /*"), + "bitcoin::address::Address"|"bitcoin::Address" => Some(""), + "std::time::Duration"|"core::time::Duration" => Some("core::time::Duration::from_secs("), "std::time::SystemTime" => Some("(::std::time::SystemTime::UNIX_EPOCH + std::time::Duration::from_secs("), @@ -1327,6 +1329,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "core::num::ParseIntError" => Some("*/"), "core::str::Utf8Error" => Some("*/"), + "bitcoin::address::Address"|"bitcoin::Address" => Some(".into_rust()"), + "std::time::Duration"|"core::time::Duration" => Some(")"), "std::time::SystemTime" => Some("))"), @@ -1442,7 +1446,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "str" => Some(""), "alloc::string::String"|"String"|"std::path::PathBuf" => Some(""), - "bitcoin::address::Address"|"bitcoin::Address" => Some("alloc::string::ToString::to_string(&"), + "bitcoin::address::Address"|"bitcoin::Address" if is_ref => Some("crate::c_types::Address::from_rust("), + "bitcoin::address::Address"|"bitcoin::Address" if !is_ref => Some("crate::c_types::Address::from_rust(&"), "std::time::Duration"|"core::time::Duration" => Some(""), "std::time::SystemTime" => Some(""), @@ -1558,7 +1563,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "alloc::string::String"|"String"|"std::path::PathBuf" if is_ref => Some(".as_str().into()"), "alloc::string::String"|"String"|"std::path::PathBuf" => Some(".into()"), - "bitcoin::address::Address"|"bitcoin::Address" => Some(").into()"), + "bitcoin::address::Address"|"bitcoin::Address" => Some(")"), "std::time::Duration"|"core::time::Duration" => Some(".as_secs()"), "std::time::SystemTime" => Some(".duration_since(::std::time::SystemTime::UNIX_EPOCH).expect(\"Times must be post-1970\").as_secs()"), diff --git a/genbindings.sh b/genbindings.sh index ce40ec0a..be9d2ece 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -241,6 +241,9 @@ if [ "$CFLAGS_aarch64_apple_darwin" != "" -a "$HOST_OSX" = "true" ]; then fi cbindgen -v --config cbindgen.toml -o include/lightning.h >/dev/null 2>&1 +echo "struct LDKBitcoinAddress;" >> include/ldk_rust_types.h +echo "typedef struct LDKBitcoinAddress LDKBitcoinAddress;" >> include/ldk_rust_types.h + # cbindgen is relatively braindead when exporting typedefs - # it happily exports all our typedefs for private types, even with the # generics we specified in C mode! So we drop all those types manually here. diff --git a/lightning-c-bindings/src/c_types/mod.rs b/lightning-c-bindings/src/c_types/mod.rs index 5fd9857c..75e01723 100644 --- a/lightning-c-bindings/src/c_types/mod.rs +++ b/lightning-c-bindings/src/c_types/mod.rs @@ -5,7 +5,7 @@ pub mod derived; use bitcoin::Transaction as BitcoinTransaction; use bitcoin::Witness as BitcoinWitness; -use bitcoin::address; +use bitcoin::Address as BitcoinAddress; use bitcoin::WitnessProgram as BitcoinWitnessProgram; use bitcoin::WitnessVersion as BitcoinWitnessVersion; use bitcoin::key::TweakedPublicKey as BitcoinTweakedPublicKey; @@ -22,7 +22,11 @@ use bitcoin::secp256k1::Scalar as SecpScalar; use bech32; use core::convert::TryInto; // Bindings need at least rustc 1.34 +use core::str::FromStr; + use alloc::borrow::ToOwned; +use alloc::string::ToString; + use core::ffi::c_void; pub(crate) use bitcoin::io::{self, Cursor, Read}; @@ -149,6 +153,43 @@ pub extern "C" fn WitnessProgram_clone(orig: &WitnessProgram) -> WitnessProgram /// Releases any memory held by the given `WitnessProgram` (which is currently none) pub extern "C" fn WitnessProgram_free(o: WitnessProgram) { } +#[derive(Clone)] +#[repr(C)] +/// Represents a valid Bitcoin on-chain address. +pub struct Address { + address: Box, +} +impl Address { + pub(crate) fn into_rust(&self) -> BitcoinAddress { + (*self.address).clone() + } + pub(crate) fn from_rust(address: &BitcoinAddress) -> Self { + Self { address: Box::new(address.clone()) } + } +} + +#[no_mangle] +/// Gets the string representation of the address in `addr` +pub extern "C" fn Address_to_string(addr: &Address) -> Str { + addr.address.to_string().into() +} +#[no_mangle] +/// Constructs a new `Address` (option) from the given string representation. +/// +/// Returns `None` only if the address is invalid. +pub extern "C" fn Address_new(s: Str) -> derived::COption_AddressZ { + match BitcoinAddress::from_str(s.into_str()) { + Ok(a) => derived::COption_AddressZ::Some(Address { address: Box::new(a.assume_checked()) }), + Err(_) => derived::COption_AddressZ::None, + } +} +#[no_mangle] +/// Releases any memory held by the given `Address` +pub extern "C" fn Address_free(o: Address) { } +#[no_mangle] +/// Creates a new Address which has the same data as `orig` +pub extern "C" fn Address_clone(orig: &Address) -> Address { orig.clone() } + #[derive(Clone)] #[repr(C)] /// Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. From fe202846adbfe3ef3166cf260b84ea0a85656d81 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 4 Apr 2025 18:30:28 +0000 Subject: [PATCH 05/12] =?UTF-8?q?Add=20`lightning-liquidity`=20to=20bindin?= =?UTF-8?q?gs=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deterministic-build-wrappers/rustc | 2 +- genbindings.sh | 2 ++ lightning-c-bindings/Cargo.toml | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/deterministic-build-wrappers/rustc b/deterministic-build-wrappers/rustc index e8983fd0..6a1162b0 100755 --- a/deterministic-build-wrappers/rustc +++ b/deterministic-build-wrappers/rustc @@ -11,7 +11,7 @@ SKIP_EMBED_BITCODE=false for ((i=0; i<"${#args[@]}"; ++i)); do case ${args[i]} in --crate-name) - if [ "${args[i+1]}" = "lightning" -o "${args[i+1]}" = "lightning_types" -o "${args[i+1]}" = "lightning_background_processor" -o "${args[i+1]}" = "lightning_invoice" -o "${args[i+1]}" = "lightning_persister" -o "${args[i+1]}" = "lightning_rapid_gossip_sync" -o "${args[i+1]}" = "lightning_transaction_sync" -o "${args[i+1]}" = "ldk" ]; then + if [ "${args[i+1]}" = "lightning" -o "${args[i+1]}" = "lightning_types" -o "${args[i+1]}" = "lightning_background_processor" -o "${args[i+1]}" = "lightning_invoice" -o "${args[i+1]}" = "lightning_persister" -o "${args[i+1]}" = "lightning_rapid_gossip_sync" -o "${args[i+1]}" = "lightning_liquidity" -o "${args[i+1]}" = "lightning_transaction_sync" -o "${args[i+1]}" = "ldk" ]; then IS_LIGHTNING=true fi ;; diff --git a/genbindings.sh b/genbindings.sh index be9d2ece..ea8a0455 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -207,6 +207,7 @@ if [ "$2" = "true" ]; then add_crate "lightning-background-processor" "lightning_background_processor" --features=std,lightning/std add_crate "lightning-invoice" "lightning_invoice" --features=std add_crate "lightning-rapid-gossip-sync" "lightning_rapid_gossip_sync" --features=std,lightning/std + add_crate "lightning-liquidity" "lightning_liquidity" --features=std,lightning/std CARGO_BUILD_ARGS="--features=std" else add_crate lightning lightning --features=dnssec @@ -215,6 +216,7 @@ else add_crate "lightning-background-processor" "lightning_background_processor" add_crate "lightning-rapid-gossip-sync" "lightning_rapid_gossip_sync" add_crate "lightning-invoice" "lightning_invoice" + add_crate "lightning-liquidity" "lightning_liquidity" CARGO_BUILD_ARGS="--features=no-std" fi diff --git a/lightning-c-bindings/Cargo.toml b/lightning-c-bindings/Cargo.toml index a6a7c6b0..62480666 100644 --- a/lightning-c-bindings/Cargo.toml +++ b/lightning-c-bindings/Cargo.toml @@ -16,7 +16,7 @@ crate-type = ["staticlib" [features] no-std = ["lightning/dnssec"] -std = ["bitcoin/std", "lightning/std", "lightning/dnssec", "lightning-invoice/std", "lightning-background-processor/std", "lightning-rapid-gossip-sync/std"] +std = ["bitcoin/std", "lightning/std", "lightning/dnssec", "lightning-invoice/std", "lightning-background-processor/std", "lightning-rapid-gossip-sync/std", "lightning-liquidity/std"] [dependencies] bitcoin = { version = "0.32", default-features = false } @@ -29,6 +29,7 @@ lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.1-bindings", default-features = false } lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.1-bindings", default-features = false } lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.1-bindings", default-features = false } +lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.1-bindings", default-features = false } # Always force panic=abort, further options are set in the genbindings.sh build script [profile.dev] From 1eb20ff259ccb2579819f59868958db8e5e769a9 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 4 Apr 2025 18:31:00 +0000 Subject: [PATCH 06/12] Enforce no invalid `cfg` flags ...and explicitly allow `test_mod_pointers` so new rustc doesn't spit out a ton of warnings --- lightning-c-bindings/Cargo.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lightning-c-bindings/Cargo.toml b/lightning-c-bindings/Cargo.toml index 62480666..b96ff164 100644 --- a/lightning-c-bindings/Cargo.toml +++ b/lightning-c-bindings/Cargo.toml @@ -37,3 +37,9 @@ panic = "abort" [profile.release] panic = "abort" + +[lints.rust.unexpected_cfgs] +level = "forbid" +check-cfg = [ + "cfg(test_mod_pointers)", +] From 48950647c887bf2bcfcb6befb453ca29f4a60ff8 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 4 Apr 2025 18:31:48 +0000 Subject: [PATCH 07/12] Update auto-generted bindings --- lightning-c-bindings/include/ldk_rust_types.h | 72 + lightning-c-bindings/include/lightning.h | 27600 +++++++++------- lightning-c-bindings/include/lightningpp.hpp | 1377 +- lightning-c-bindings/src/c_types/derived.rs | 686 +- lightning-c-bindings/src/lib.rs | 1 + lightning-c-bindings/src/lightning/ln/msgs.rs | 4 + .../src/lightning/ln/peer_handler.rs | 2 + .../src/lightning/offers/invoice.rs | 8 +- .../src/lightning_invoice/mod.rs | 16 +- .../src/lightning_liquidity/events.rs | 208 + .../src/lightning_liquidity/lsps0/client.rs | 93 + .../src/lightning_liquidity/lsps0/event.rs | 125 + .../src/lightning_liquidity/lsps0/mod.rs | 24 + .../src/lightning_liquidity/lsps0/msgs.rs | 601 + .../src/lightning_liquidity/lsps0/ser.rs | 803 + .../src/lightning_liquidity/lsps0/service.rs | 83 + .../src/lightning_liquidity/lsps1/client.rs | 222 + .../src/lightning_liquidity/lsps1/event.rs | 457 + .../src/lightning_liquidity/lsps1/mod.rs | 22 + .../src/lightning_liquidity/lsps1/msgs.rs | 2617 ++ .../src/lightning_liquidity/lsps2/client.rs | 224 + .../src/lightning_liquidity/lsps2/event.rs | 502 + .../src/lightning_liquidity/lsps2/mod.rs | 36 + .../src/lightning_liquidity/lsps2/msgs.rs | 1389 + .../src/lightning_liquidity/lsps2/service.rs | 292 + .../src/lightning_liquidity/lsps2/utils.rs | 45 + .../src/lightning_liquidity/message_queue.rs | 145 + .../src/lightning_liquidity/mod.rs | 127 + 28 files changed, 25846 insertions(+), 11935 deletions(-) create mode 100644 lightning-c-bindings/src/lightning_liquidity/events.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps0/client.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps0/event.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps0/mod.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps0/msgs.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps0/ser.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps0/service.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps1/client.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps1/event.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps1/mod.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps1/msgs.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps2/client.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps2/event.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps2/mod.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps2/msgs.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps2/service.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/lsps2/utils.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/message_queue.rs create mode 100644 lightning-c-bindings/src/lightning_liquidity/mod.rs diff --git a/lightning-c-bindings/include/ldk_rust_types.h b/lightning-c-bindings/include/ldk_rust_types.h index 1b790ed2..dccc05ed 100644 --- a/lightning-c-bindings/include/ldk_rust_types.h +++ b/lightning-c-bindings/include/ldk_rust_types.h @@ -24,6 +24,8 @@ struct nativeHumanReadableNameOpaque; typedef struct nativeHumanReadableNameOpaque LDKnativeHumanReadableName; struct nativeOMNameResolverOpaque; typedef struct nativeOMNameResolverOpaque LDKnativeOMNameResolver; +struct nativeLSPS0ClientHandlerOpaque; +typedef struct nativeLSPS0ClientHandlerOpaque LDKnativeLSPS0ClientHandler; struct nativeInvoiceWithExplicitSigningPubkeyBuilderOpaque; typedef struct nativeInvoiceWithExplicitSigningPubkeyBuilderOpaque LDKnativeInvoiceWithExplicitSigningPubkeyBuilder; struct nativeInvoiceWithDerivedSigningPubkeyBuilderOpaque; @@ -79,6 +81,10 @@ struct nativeBlindedPathCandidateOpaque; typedef struct nativeBlindedPathCandidateOpaque LDKnativeBlindedPathCandidate; struct nativeOneHopBlindedPathCandidateOpaque; typedef struct nativeOneHopBlindedPathCandidateOpaque LDKnativeOneHopBlindedPathCandidate; +struct nativeLSPS0ListProtocolsRequestOpaque; +typedef struct nativeLSPS0ListProtocolsRequestOpaque LDKnativeLSPS0ListProtocolsRequest; +struct nativeLSPS0ListProtocolsResponseOpaque; +typedef struct nativeLSPS0ListProtocolsResponseOpaque LDKnativeLSPS0ListProtocolsResponse; struct nativeUntrustedStringOpaque; typedef struct nativeUntrustedStringOpaque LDKnativeUntrustedString; struct nativePrintableStringOpaque; @@ -103,6 +109,14 @@ struct nativeBestBlockOpaque; typedef struct nativeBestBlockOpaque LDKnativeBestBlock; struct nativeWatchedOutputOpaque; typedef struct nativeWatchedOutputOpaque LDKnativeWatchedOutput; +struct nativeLSPS1ClientConfigOpaque; +typedef struct nativeLSPS1ClientConfigOpaque LDKnativeLSPS1ClientConfig; +struct nativeLSPS1ClientHandlerOpaque; +typedef struct nativeLSPS1ClientHandlerOpaque LDKnativeLSPS1ClientHandler; +struct nativeLSPS2ClientConfigOpaque; +typedef struct nativeLSPS2ClientConfigOpaque LDKnativeLSPS2ClientConfig; +struct nativeLSPS2ClientHandlerOpaque; +typedef struct nativeLSPS2ClientHandlerOpaque LDKnativeLSPS2ClientHandler; struct nativeOfferIdOpaque; typedef struct nativeOfferIdOpaque LDKnativeOfferId; struct nativeOfferWithExplicitMetadataBuilderOpaque; @@ -171,6 +185,10 @@ struct nativeUserConfigOpaque; typedef struct nativeUserConfigOpaque LDKnativeUserConfig; struct nativeTaggedHashOpaque; typedef struct nativeTaggedHashOpaque LDKnativeTaggedHash; +struct nativeLSPS2ServiceConfigOpaque; +typedef struct nativeLSPS2ServiceConfigOpaque LDKnativeLSPS2ServiceConfig; +struct nativeLSPS2ServiceHandlerOpaque; +typedef struct nativeLSPS2ServiceHandlerOpaque LDKnativeLSPS2ServiceHandler; struct nativeChannelMonitorUpdateOpaque; typedef struct nativeChannelMonitorUpdateOpaque LDKnativeChannelMonitorUpdate; struct nativeHTLCUpdateOpaque; @@ -325,6 +343,32 @@ struct nativeOnionPacketOpaque; typedef struct nativeOnionPacketOpaque LDKnativeOnionPacket; struct nativeTrampolineOnionPacketOpaque; typedef struct nativeTrampolineOnionPacketOpaque LDKnativeTrampolineOnionPacket; +struct nativeLSPS1OrderIdOpaque; +typedef struct nativeLSPS1OrderIdOpaque LDKnativeLSPS1OrderId; +struct nativeLSPS1GetInfoRequestOpaque; +typedef struct nativeLSPS1GetInfoRequestOpaque LDKnativeLSPS1GetInfoRequest; +struct nativeLSPS1OptionsOpaque; +typedef struct nativeLSPS1OptionsOpaque LDKnativeLSPS1Options; +struct nativeLSPS1GetInfoResponseOpaque; +typedef struct nativeLSPS1GetInfoResponseOpaque LDKnativeLSPS1GetInfoResponse; +struct nativeLSPS1CreateOrderRequestOpaque; +typedef struct nativeLSPS1CreateOrderRequestOpaque LDKnativeLSPS1CreateOrderRequest; +struct nativeLSPS1OrderParamsOpaque; +typedef struct nativeLSPS1OrderParamsOpaque LDKnativeLSPS1OrderParams; +struct nativeLSPS1CreateOrderResponseOpaque; +typedef struct nativeLSPS1CreateOrderResponseOpaque LDKnativeLSPS1CreateOrderResponse; +struct nativeLSPS1PaymentInfoOpaque; +typedef struct nativeLSPS1PaymentInfoOpaque LDKnativeLSPS1PaymentInfo; +struct nativeLSPS1Bolt11PaymentInfoOpaque; +typedef struct nativeLSPS1Bolt11PaymentInfoOpaque LDKnativeLSPS1Bolt11PaymentInfo; +struct nativeLSPS1OnchainPaymentInfoOpaque; +typedef struct nativeLSPS1OnchainPaymentInfoOpaque LDKnativeLSPS1OnchainPaymentInfo; +struct nativeLSPS1OnchainPaymentOpaque; +typedef struct nativeLSPS1OnchainPaymentOpaque LDKnativeLSPS1OnchainPayment; +struct nativeLSPS1ChannelInfoOpaque; +typedef struct nativeLSPS1ChannelInfoOpaque LDKnativeLSPS1ChannelInfo; +struct nativeLSPS1GetOrderRequestOpaque; +typedef struct nativeLSPS1GetOrderRequestOpaque LDKnativeLSPS1GetOrderRequest; struct nativeRecordOpaque; typedef struct nativeRecordOpaque LDKnativeRecord; struct nativeInboundHTLCDetailsOpaque; @@ -341,6 +385,14 @@ struct nativeFutureOpaque; typedef struct nativeFutureOpaque LDKnativeFuture; struct nativeSleeperOpaque; typedef struct nativeSleeperOpaque LDKnativeSleeper; +struct nativeRawLSPSMessageOpaque; +typedef struct nativeRawLSPSMessageOpaque LDKnativeRawLSPSMessage; +struct nativeLSPSRequestIdOpaque; +typedef struct nativeLSPSRequestIdOpaque LDKnativeLSPSRequestId; +struct nativeLSPSDateTimeOpaque; +typedef struct nativeLSPSDateTimeOpaque LDKnativeLSPSDateTime; +struct nativeLSPSResponseErrorOpaque; +typedef struct nativeLSPSResponseErrorOpaque LDKnativeLSPSResponseError; struct nativeHeldHtlcAvailableOpaque; typedef struct nativeHeldHtlcAvailableOpaque LDKnativeHeldHtlcAvailable; struct nativeReleaseHeldHtlcOpaque; @@ -377,6 +429,20 @@ struct nativeInvalidShutdownScriptOpaque; typedef struct nativeInvalidShutdownScriptOpaque LDKnativeInvalidShutdownScript; struct nativeBolt12ParseErrorOpaque; typedef struct nativeBolt12ParseErrorOpaque LDKnativeBolt12ParseError; +struct nativeLSPS2GetInfoRequestOpaque; +typedef struct nativeLSPS2GetInfoRequestOpaque LDKnativeLSPS2GetInfoRequest; +struct nativeLSPS2RawOpeningFeeParamsOpaque; +typedef struct nativeLSPS2RawOpeningFeeParamsOpaque LDKnativeLSPS2RawOpeningFeeParams; +struct nativeLSPS2OpeningFeeParamsOpaque; +typedef struct nativeLSPS2OpeningFeeParamsOpaque LDKnativeLSPS2OpeningFeeParams; +struct nativeLSPS2GetInfoResponseOpaque; +typedef struct nativeLSPS2GetInfoResponseOpaque LDKnativeLSPS2GetInfoResponse; +struct nativeLSPS2BuyRequestOpaque; +typedef struct nativeLSPS2BuyRequestOpaque LDKnativeLSPS2BuyRequest; +struct nativeLSPS2InterceptScidOpaque; +typedef struct nativeLSPS2InterceptScidOpaque LDKnativeLSPS2InterceptScid; +struct nativeLSPS2BuyResponseOpaque; +typedef struct nativeLSPS2BuyResponseOpaque LDKnativeLSPS2BuyResponse; struct nativePacketOpaque; typedef struct nativePacketOpaque LDKnativePacket; struct nativeClaimedHTLCOpaque; @@ -483,6 +549,8 @@ struct nativeEmptyNodeIdLookUpOpaque; typedef struct nativeEmptyNodeIdLookUpOpaque LDKnativeEmptyNodeIdLookUp; struct nativeBlindedHopOpaque; typedef struct nativeBlindedHopOpaque LDKnativeBlindedHop; +struct nativeMessageQueueOpaque; +typedef struct nativeMessageQueueOpaque LDKnativeMessageQueue; struct nativeInvoiceErrorOpaque; typedef struct nativeInvoiceErrorOpaque LDKnativeInvoiceError; struct nativeErroneousFieldOpaque; @@ -507,9 +575,13 @@ struct nativeLockedChannelMonitorOpaque; typedef struct nativeLockedChannelMonitorOpaque LDKnativeLockedChannelMonitor; struct nativeChainMonitorOpaque; typedef struct nativeChainMonitorOpaque LDKnativeChainMonitor; +struct nativeLSPS0ServiceHandlerOpaque; +typedef struct nativeLSPS0ServiceHandlerOpaque LDKnativeLSPS0ServiceHandler; struct nativeBlindedMessagePathOpaque; typedef struct nativeBlindedMessagePathOpaque LDKnativeBlindedMessagePath; struct nativeMessageForwardNodeOpaque; typedef struct nativeMessageForwardNodeOpaque LDKnativeMessageForwardNode; struct nativeDNSResolverContextOpaque; typedef struct nativeDNSResolverContextOpaque LDKnativeDNSResolverContext; +struct LDKBitcoinAddress; +typedef struct LDKBitcoinAddress LDKBitcoinAddress; diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 2d92e4e4..6b94f06c 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -702,6 +702,53 @@ typedef enum LDKInboundHTLCStateDetails { LDKInboundHTLCStateDetails_Sentinel, } LDKInboundHTLCStateDetails; +/** + * An object representing the status of an order. + */ +typedef enum LDKLSPS1OrderState { + /** + * The order has been created. + */ + LDKLSPS1OrderState_Created, + /** + * The LSP has opened the channel and published the funding transaction. + */ + LDKLSPS1OrderState_Completed, + /** + * The order failed. + */ + LDKLSPS1OrderState_Failed, + /** + * Must be last for serialization purposes + */ + LDKLSPS1OrderState_Sentinel, +} LDKLSPS1OrderState; + +/** + * The state of a payment. + * + * *Note*: Previously, the spec also knew a `CANCELLED` state for BOLT11 payments, which has since + * been deprecated and `REFUNDED` should be used instead. + */ +typedef enum LDKLSPS1PaymentState { + /** + * A payment is expected. + */ + LDKLSPS1PaymentState_ExpectPayment, + /** + * A sufficient payment has been received. + */ + LDKLSPS1PaymentState_Paid, + /** + * The payment has been refunded. + */ + LDKLSPS1PaymentState_Refunded, + /** + * Must be last for serialization purposes + */ + LDKLSPS1PaymentState_Sentinel, +} LDKLSPS1PaymentState; + /** * An enum representing the available verbosity levels of the logger. */ @@ -1201,6 +1248,40 @@ typedef struct LDKu8slice { uintptr_t datalen; } LDKu8slice; +/** + * Represents a valid Bitcoin on-chain address. + */ +typedef struct LDKAddress { + LDKBitcoinAddress *NONNULL_PTR address; +} LDKAddress; + +/** + * An enum which can either contain a crate::c_types::Address or not + */ +typedef enum LDKCOption_AddressZ_Tag { + /** + * When we're in this state, this COption_AddressZ contains a crate::c_types::Address + */ + LDKCOption_AddressZ_Some, + /** + * When we're in this state, this COption_AddressZ contains nothing + */ + LDKCOption_AddressZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_AddressZ_Sentinel, +} LDKCOption_AddressZ_Tag; + +typedef struct LDKCOption_AddressZ { + LDKCOption_AddressZ_Tag tag; + union { + struct { + struct LDKAddress some; + }; + }; +} LDKCOption_AddressZ; + /** * Represents a scalar value between zero and the secp256k1 curve order, in big endian. */ @@ -3011,20 +3092,20 @@ typedef struct LDKCVec_BlindedPaymentPathZ { } LDKCVec_BlindedPaymentPathZ; /** - * A dynamically-allocated array of crate::c_types::Strs of arbitrary size. + * A dynamically-allocated array of crate::c_types::Addresss of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_StrZ { +typedef struct LDKCVec_AddressZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKStr *data; + struct LDKAddress *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_StrZ; +} LDKCVec_AddressZ; /** * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. @@ -6019,6 +6100,22 @@ typedef struct LDKCVec_PublicKeyZ { uintptr_t datalen; } LDKCVec_PublicKeyZ; +/** + * A dynamically-allocated array of u16s of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_u16Z { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + uint16_t *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_u16Z; + /** @@ -6900,6 +6997,234 @@ typedef struct LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { uintptr_t datalen; } LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ; +/** + * An enum which can either contain a crate::c_types::Str or not + */ +typedef enum LDKCOption_StrZ_Tag { + /** + * When we're in this state, this COption_StrZ contains a crate::c_types::Str + */ + LDKCOption_StrZ_Some, + /** + * When we're in this state, this COption_StrZ contains nothing + */ + LDKCOption_StrZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_StrZ_Sentinel, +} LDKCOption_StrZ_Tag; + +typedef struct LDKCOption_StrZ { + LDKCOption_StrZ_Tag tag; + union { + struct { + struct LDKStr some; + }; + }; +} LDKCOption_StrZ; + + + +/** + * A JSON-RPC request's `id`. + * + * Please refer to the [JSON-RPC 2.0 specification](https://www.jsonrpc.org/specification#request_object) for + * more information. + */ +typedef struct MUST_USE_STRUCT LDKLSPSRequestId { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPSRequestId *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPSRequestId; + +/** + * Indicates an error on the client's part (usually some variant of attempting to use too-low or + * too-high values) + */ +typedef enum LDKAPIError_Tag { + /** + * Indicates the API was wholly misused (see err for more). Cases where these can be returned + * are documented, but generally indicates some precondition of a function was violated. + */ + LDKAPIError_APIMisuseError, + /** + * Due to a high feerate, we were unable to complete the request. + * For example, this may be returned if the feerate implies we cannot open a channel at the + * requested value, but opening a larger channel would succeed. + */ + LDKAPIError_FeeRateTooHigh, + /** + * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, + * too-many-hops, etc). + */ + LDKAPIError_InvalidRoute, + /** + * We were unable to complete the request as the Channel required to do so is unable to + * complete the request (or was not found). This can take many forms, including disconnected + * peer, channel at capacity, channel shutting down, etc. + */ + LDKAPIError_ChannelUnavailable, + /** + * An attempt to call [`chain::Watch::watch_channel`]/[`chain::Watch::update_channel`] + * returned a [`ChannelMonitorUpdateStatus::InProgress`] indicating the persistence of a + * monitor update is awaiting async resolution. Once it resolves the attempted action should + * complete automatically. + * + * [`chain::Watch::watch_channel`]: crate::chain::Watch::watch_channel + * [`chain::Watch::update_channel`]: crate::chain::Watch::update_channel + * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress + */ + LDKAPIError_MonitorUpdateInProgress, + /** + * [`SignerProvider::get_shutdown_scriptpubkey`] returned a shutdown scriptpubkey incompatible + * with the channel counterparty as negotiated in [`InitFeatures`]. + * + * Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open + * a channel or cooperatively close one with this peer (and will have to force-close instead). + * + * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey + * [`InitFeatures`]: crate::types::features::InitFeatures + */ + LDKAPIError_IncompatibleShutdownScript, + /** + * Must be last for serialization purposes + */ + LDKAPIError_Sentinel, +} LDKAPIError_Tag; + +typedef struct LDKAPIError_LDKAPIMisuseError_Body { + /** + * A human-readable error message + */ + struct LDKStr err; +} LDKAPIError_LDKAPIMisuseError_Body; + +typedef struct LDKAPIError_LDKFeeRateTooHigh_Body { + /** + * A human-readable error message + */ + struct LDKStr err; + /** + * The feerate which was too high. + */ + uint32_t feerate; +} LDKAPIError_LDKFeeRateTooHigh_Body; + +typedef struct LDKAPIError_LDKInvalidRoute_Body { + /** + * A human-readable error message + */ + struct LDKStr err; +} LDKAPIError_LDKInvalidRoute_Body; + +typedef struct LDKAPIError_LDKChannelUnavailable_Body { + /** + * A human-readable error message + */ + struct LDKStr err; +} LDKAPIError_LDKChannelUnavailable_Body; + +typedef struct LDKAPIError_LDKIncompatibleShutdownScript_Body { + /** + * The incompatible shutdown script. + */ + struct LDKShutdownScript script; +} LDKAPIError_LDKIncompatibleShutdownScript_Body; + +typedef struct MUST_USE_STRUCT LDKAPIError { + LDKAPIError_Tag tag; + union { + LDKAPIError_LDKAPIMisuseError_Body api_misuse_error; + LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high; + LDKAPIError_LDKInvalidRoute_Body invalid_route; + LDKAPIError_LDKChannelUnavailable_Body channel_unavailable; + LDKAPIError_LDKIncompatibleShutdownScript_Body incompatible_shutdown_script; + }; +} LDKAPIError; + +/** + * The contents of CResult_LSPSRequestIdAPIErrorZ + */ +typedef union LDKCResult_LSPSRequestIdAPIErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKLSPSRequestId *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKAPIError *err; +} LDKCResult_LSPSRequestIdAPIErrorZPtr; + +/** + * A CResult_LSPSRequestIdAPIErrorZ represents the result of a fallible operation, + * containing a crate::lightning_liquidity::lsps0::ser::LSPSRequestId on success and a crate::lightning::util::errors::APIError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_LSPSRequestIdAPIErrorZ { + /** + * The contents of this CResult_LSPSRequestIdAPIErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_LSPSRequestIdAPIErrorZPtr contents; + /** + * Whether this CResult_LSPSRequestIdAPIErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_LSPSRequestIdAPIErrorZ; + + + +/** + * Fees and parameters for a JIT Channel including the promise. + * + * The promise is an HMAC calculated using a secret known to the LSP and the rest of the fields as input. + * It exists so the LSP can verify the authenticity of a client provided LSPS2OpeningFeeParams by recalculating + * the promise using the secret. Once verified they can be confident it was not modified by the client. + */ +typedef struct MUST_USE_STRUCT LDKLSPS2OpeningFeeParams { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS2OpeningFeeParams *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS2OpeningFeeParams; + +/** + * A dynamically-allocated array of crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParamss of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_LSPS2OpeningFeeParamsZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKLSPS2OpeningFeeParams *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_LSPS2OpeningFeeParamsZ; + /** @@ -10176,111 +10501,6 @@ typedef struct LDKCOption_C2Tuple_u64u16ZZ { }; } LDKCOption_C2Tuple_u64u16ZZ; -/** - * Indicates an error on the client's part (usually some variant of attempting to use too-low or - * too-high values) - */ -typedef enum LDKAPIError_Tag { - /** - * Indicates the API was wholly misused (see err for more). Cases where these can be returned - * are documented, but generally indicates some precondition of a function was violated. - */ - LDKAPIError_APIMisuseError, - /** - * Due to a high feerate, we were unable to complete the request. - * For example, this may be returned if the feerate implies we cannot open a channel at the - * requested value, but opening a larger channel would succeed. - */ - LDKAPIError_FeeRateTooHigh, - /** - * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, - * too-many-hops, etc). - */ - LDKAPIError_InvalidRoute, - /** - * We were unable to complete the request as the Channel required to do so is unable to - * complete the request (or was not found). This can take many forms, including disconnected - * peer, channel at capacity, channel shutting down, etc. - */ - LDKAPIError_ChannelUnavailable, - /** - * An attempt to call [`chain::Watch::watch_channel`]/[`chain::Watch::update_channel`] - * returned a [`ChannelMonitorUpdateStatus::InProgress`] indicating the persistence of a - * monitor update is awaiting async resolution. Once it resolves the attempted action should - * complete automatically. - * - * [`chain::Watch::watch_channel`]: crate::chain::Watch::watch_channel - * [`chain::Watch::update_channel`]: crate::chain::Watch::update_channel - * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress - */ - LDKAPIError_MonitorUpdateInProgress, - /** - * [`SignerProvider::get_shutdown_scriptpubkey`] returned a shutdown scriptpubkey incompatible - * with the channel counterparty as negotiated in [`InitFeatures`]. - * - * Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open - * a channel or cooperatively close one with this peer (and will have to force-close instead). - * - * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey - * [`InitFeatures`]: crate::types::features::InitFeatures - */ - LDKAPIError_IncompatibleShutdownScript, - /** - * Must be last for serialization purposes - */ - LDKAPIError_Sentinel, -} LDKAPIError_Tag; - -typedef struct LDKAPIError_LDKAPIMisuseError_Body { - /** - * A human-readable error message - */ - struct LDKStr err; -} LDKAPIError_LDKAPIMisuseError_Body; - -typedef struct LDKAPIError_LDKFeeRateTooHigh_Body { - /** - * A human-readable error message - */ - struct LDKStr err; - /** - * The feerate which was too high. - */ - uint32_t feerate; -} LDKAPIError_LDKFeeRateTooHigh_Body; - -typedef struct LDKAPIError_LDKInvalidRoute_Body { - /** - * A human-readable error message - */ - struct LDKStr err; -} LDKAPIError_LDKInvalidRoute_Body; - -typedef struct LDKAPIError_LDKChannelUnavailable_Body { - /** - * A human-readable error message - */ - struct LDKStr err; -} LDKAPIError_LDKChannelUnavailable_Body; - -typedef struct LDKAPIError_LDKIncompatibleShutdownScript_Body { - /** - * The incompatible shutdown script. - */ - struct LDKShutdownScript script; -} LDKAPIError_LDKIncompatibleShutdownScript_Body; - -typedef struct MUST_USE_STRUCT LDKAPIError { - LDKAPIError_Tag tag; - union { - LDKAPIError_LDKAPIMisuseError_Body api_misuse_error; - LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high; - LDKAPIError_LDKInvalidRoute_Body invalid_route; - LDKAPIError_LDKChannelUnavailable_Body channel_unavailable; - LDKAPIError_LDKIncompatibleShutdownScript_Body incompatible_shutdown_script; - }; -} LDKAPIError; - /** * The contents of CResult_ChannelIdAPIErrorZ */ @@ -10998,33 +11218,6 @@ typedef struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { bool result_ok; } LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ; -/** - * An enum which can either contain a crate::c_types::Str or not - */ -typedef enum LDKCOption_StrZ_Tag { - /** - * When we're in this state, this COption_StrZ contains a crate::c_types::Str - */ - LDKCOption_StrZ_Some, - /** - * When we're in this state, this COption_StrZ contains nothing - */ - LDKCOption_StrZ_None, - /** - * Must be last for serialization purposes - */ - LDKCOption_StrZ_Sentinel, -} LDKCOption_StrZ_Tag; - -typedef struct LDKCOption_StrZ { - LDKCOption_StrZ_Tag tag; - union { - struct { - struct LDKStr some; - }; - }; -} LDKCOption_StrZ; - /** * A dynamically-allocated array of crate::lightning::onion_message::messenger::Destinations of arbitrary size. * This corresponds to std::vector in C++ @@ -13634,6 +13827,45 @@ typedef struct LDKCResult_COption_APIErrorZDecodeErrorZ { bool result_ok; } LDKCResult_COption_APIErrorZDecodeErrorZ; + + +/** + * Fees and parameters for a JIT Channel without the promise. + * + * The promise will be calculated automatically for the LSP and this type converted + * into an [`LSPS2OpeningFeeParams`] for transit over the wire. + */ +typedef struct MUST_USE_STRUCT LDKLSPS2RawOpeningFeeParams { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS2RawOpeningFeeParams *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS2RawOpeningFeeParams; + +/** + * A dynamically-allocated array of crate::lightning_liquidity::lsps2::msgs::LSPS2RawOpeningFeeParamss of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_LSPS2RawOpeningFeeParamsZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKLSPS2RawOpeningFeeParams *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_LSPS2RawOpeningFeeParamsZ; + /** * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ */ @@ -14834,6 +15066,22 @@ typedef struct LDKCResult_CVec_u8ZIOErrorZ { bool result_ok; } LDKCResult_CVec_u8ZIOErrorZ; +/** + * A dynamically-allocated array of crate::c_types::Strs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_StrZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKStr *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_StrZ; + /** * The contents of CResult_CVec_StrZIOErrorZ */ @@ -18179,6 +18427,111 @@ typedef struct LDKCVec_FutureZ { uintptr_t datalen; } LDKCVec_FutureZ; + + +/** + * Lightning message type used by LSPS protocols. + */ +typedef struct MUST_USE_STRUCT LDKRawLSPSMessage { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRawLSPSMessage *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKRawLSPSMessage; + +/** + * The contents of CResult_RawLSPSMessageDecodeErrorZ + */ +typedef union LDKCResult_RawLSPSMessageDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKRawLSPSMessage *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_RawLSPSMessageDecodeErrorZPtr; + +/** + * A CResult_RawLSPSMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning_liquidity::lsps0::ser::RawLSPSMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_RawLSPSMessageDecodeErrorZ { + /** + * The contents of this CResult_RawLSPSMessageDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_RawLSPSMessageDecodeErrorZPtr contents; + /** + * Whether this CResult_RawLSPSMessageDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_RawLSPSMessageDecodeErrorZ; + + + +/** + * An object representing datetimes as described in bLIP-50 / LSPS0. + */ +typedef struct MUST_USE_STRUCT LDKLSPSDateTime { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPSDateTime *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPSDateTime; + +/** + * The contents of CResult_LSPSDateTimeNoneZ + */ +typedef union LDKCResult_LSPSDateTimeNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKLSPSDateTime *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_LSPSDateTimeNoneZPtr; + +/** + * A CResult_LSPSDateTimeNoneZ represents the result of a fallible operation, + * containing a crate::lightning_liquidity::lsps0::ser::LSPSDateTime on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_LSPSDateTimeNoneZ { + /** + * The contents of this CResult_LSPSDateTimeNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_LSPSDateTimeNoneZPtr contents; + /** + * Whether this CResult_LSPSDateTimeNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_LSPSDateTimeNoneZ; + /** * The contents of CResult_HeldHtlcAvailableDecodeErrorZ */ @@ -18988,6 +19341,38 @@ typedef struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ { bool result_ok; } LDKCResult_ShutdownScriptInvalidShutdownScriptZ; +/** + * The contents of CResult_u64NoneZ + */ +typedef union LDKCResult_u64NoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + uint64_t *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_u64NoneZPtr; + +/** + * A CResult_u64NoneZ represents the result of a fallible operation, + * containing a u64 on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_u64NoneZ { + /** + * The contents of this CResult_u64NoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_u64NoneZPtr contents; + /** + * Whether this CResult_u64NoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_u64NoneZ; + /** * `FundingInfo` holds information about a channel's funding transaction. * @@ -25665,6 +26050,8 @@ typedef struct LDKChannelMessageHandler { * May return an `Err(())` if the features the peer supports are not sufficient to communicate * with us. Implementors should be somewhat conservative about doing so, however, as other * message handlers may still wish to communicate with this peer. + * + * [`Self::peer_disconnected`] will not be called if `Err(())` is returned. */ struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound); /** @@ -26135,6 +26522,8 @@ typedef struct LDKOnionMessageHandler { * May return an `Err(())` if the features the peer supports are not sufficient to communicate * with us. Implementors should be somewhat conservative about doing so, however, as other * message handlers may still wish to communicate with this peer. + * + * [`Self::peer_disconnected`] will not be called if `Err(())` is returned. */ struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init, bool inbound); /** @@ -26250,6 +26639,8 @@ typedef struct LDKCustomMessageHandler { * May return an `Err(())` if the features the peer supports are not sufficient to communicate * with us. Implementors should be somewhat conservative about doing so, however, as other * message handlers may still wish to communicate with this peer. + * + * [`Self::peer_disconnected`] will not be called if `Err(())` is returned. */ struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound); /** @@ -27871,1011 +28262,2551 @@ typedef struct MUST_USE_STRUCT LDKFallback { }; } LDKFallback; -extern const uintptr_t MAX_BUF_SIZE; - -extern const uintptr_t KVSTORE_NAMESPACE_KEY_MAX_LEN; +/** + * An event which an bLIP-50 / LSPS0 client may want to take some action in response to. + */ +typedef enum LDKLSPS0ClientEvent_Tag { + /** + * Information from the LSP about the protocols they support. + */ + LDKLSPS0ClientEvent_ListProtocolsResponse, + /** + * Must be last for serialization purposes + */ + LDKLSPS0ClientEvent_Sentinel, +} LDKLSPS0ClientEvent_Tag; -extern const uint64_t MAX_SCID_BLOCK; +typedef struct LDKLSPS0ClientEvent_LDKListProtocolsResponse_Body { + /** + * The node id of the LSP. + */ + struct LDKPublicKey counterparty_node_id; + /** + * A list of supported protocols. + */ + struct LDKCVec_u16Z protocols; +} LDKLSPS0ClientEvent_LDKListProtocolsResponse_Body; -extern const uint64_t MAX_SCID_TX_INDEX; +typedef struct MUST_USE_STRUCT LDKLSPS0ClientEvent { + LDKLSPS0ClientEvent_Tag tag; + union { + LDKLSPS0ClientEvent_LDKListProtocolsResponse_Body list_protocols_response; + }; +} LDKLSPS0ClientEvent; -extern const uint64_t MAX_SCID_VOUT_INDEX; -extern const uint32_t PRUNE_DELAY_BLOCKS; -extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; +/** + * An object representing the supported protocol options. + */ +typedef struct MUST_USE_STRUCT LDKLSPS1Options { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1Options *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1Options; -extern const uint32_t FEERATE_FLOOR_SATS_PER_KW; -extern const uint32_t ANTI_REORG_DELAY; -extern const uint32_t ARCHIVAL_DELAY_BLOCKS; +/** + * An error returned in response to an JSON-RPC request. + * + * Please refer to the [JSON-RPC 2.0 specification](https://www.jsonrpc.org/specification#error_object) for + * more information. + */ +typedef struct MUST_USE_STRUCT LDKLSPSResponseError { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPSResponseError *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPSResponseError; -extern const uint16_t BREAKDOWN_TIMEOUT; -extern const uint16_t MIN_CLTV_EXPIRY_DELTA; -extern const uint16_t MIN_FINAL_CLTV_EXPIRY_DELTA; +/** + * The identifier of an order. + */ +typedef struct MUST_USE_STRUCT LDKLSPS1OrderId { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1OrderId *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1OrderId; -extern const uint16_t MAX_HTLCS; -extern const uintptr_t OFFERED_HTLC_SCRIPT_WEIGHT; -extern const uintptr_t OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS; +/** + * An object representing an bLIP-51 / LSPS1 channel order. + */ +typedef struct MUST_USE_STRUCT LDKLSPS1OrderParams { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1OrderParams *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1OrderParams; -extern const uintptr_t MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT; -extern const uint64_t ANCHOR_INPUT_WITNESS_WEIGHT; -extern const uint64_t HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT; +/** + * Details regarding how to pay for an order. + */ +typedef struct MUST_USE_STRUCT LDKLSPS1PaymentInfo { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1PaymentInfo *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1PaymentInfo; -extern const uint64_t HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT; -extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; -extern const uintptr_t PAYER_NOTE_LIMIT; +/** + * Details regarding the state of an ordered channel. + */ +typedef struct MUST_USE_STRUCT LDKLSPS1ChannelInfo { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1ChannelInfo *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1ChannelInfo; -extern const uint64_t UNKNOWN_CHANNEL_CAPACITY_MSAT; +/** + * An event which an bLIP-51 / LSPS1 client should take some action in response to. + */ +typedef enum LDKLSPS1ClientEvent_Tag { + /** + * A request previously issued via [`LSPS1ClientHandler::request_supported_options`] + * succeeded as the LSP returned the options it supports. + * + * You must check whether LSP supports the parameters the client wants and then call + * [`LSPS1ClientHandler::create_order`] to place an order. + * + * [`LSPS1ClientHandler::request_supported_options`]: crate::lsps1::client::LSPS1ClientHandler::request_supported_options + * [`LSPS1ClientHandler::create_order`]: crate::lsps1::client::LSPS1ClientHandler::create_order + */ + LDKLSPS1ClientEvent_SupportedOptionsReady, + /** + * A request previously issued via [`LSPS1ClientHandler::request_supported_options`] + * failed as the LSP returned an error response. + * + * [`LSPS1ClientHandler::request_supported_options`]: crate::lsps1::client::LSPS1ClientHandler::request_supported_options + */ + LDKLSPS1ClientEvent_SupportedOptionsRequestFailed, + /** + * Confirmation from the LSP about the order created by the client. + * + * When the payment is confirmed, the LSP will open a channel to you + * with the below agreed upon parameters. + * + * You must pay the invoice or onchain address if you want to continue and then + * call [`LSPS1ClientHandler::check_order_status`] with the order id + * to get information from LSP about progress of the order. + * + * [`LSPS1ClientHandler::check_order_status`]: crate::lsps1::client::LSPS1ClientHandler::check_order_status + */ + LDKLSPS1ClientEvent_OrderCreated, + /** + * Information from the LSP about the status of a previously created order. + * + * Will be emitted in response to calling [`LSPS1ClientHandler::check_order_status`]. + * + * [`LSPS1ClientHandler::check_order_status`]: crate::lsps1::client::LSPS1ClientHandler::check_order_status + */ + LDKLSPS1ClientEvent_OrderStatus, + /** + * A request previously issued via [`LSPS1ClientHandler::create_order`] or [`LSPS1ClientHandler::check_order_status`]. + * failed as the LSP returned an error response. + * + * [`LSPS1ClientHandler::create_order`]: crate::lsps1::client::LSPS1ClientHandler::create_order + * [`LSPS1ClientHandler::check_order_status`]: crate::lsps1::client::LSPS1ClientHandler::check_order_status + */ + LDKLSPS1ClientEvent_OrderRequestFailed, + /** + * Must be last for serialization purposes + */ + LDKLSPS1ClientEvent_Sentinel, +} LDKLSPS1ClientEvent_Tag; -extern const uint32_t DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA; +typedef struct LDKLSPS1ClientEvent_LDKSupportedOptionsReady_Body { + /** + * The identifier of the issued bLIP-51 / LSPS1 `get_info` request, as returned by + * [`LSPS1ClientHandler::request_supported_options`] + * + * This can be used to track which request this event corresponds to. + * + * [`LSPS1ClientHandler::request_supported_options`]: crate::lsps1::client::LSPS1ClientHandler::request_supported_options + */ + struct LDKLSPSRequestId request_id; + /** + * The node id of the LSP that provided this response. + */ + struct LDKPublicKey counterparty_node_id; + /** + * All options supported by the LSP. + */ + struct LDKLSPS1Options supported_options; +} LDKLSPS1ClientEvent_LDKSupportedOptionsReady_Body; -extern const uint8_t DEFAULT_MAX_PATH_COUNT; +typedef struct LDKLSPS1ClientEvent_LDKSupportedOptionsRequestFailed_Body { + /** + * The identifier of the issued bLIP-51 / LSPS1 `get_info` request, as returned by + * [`LSPS1ClientHandler::request_supported_options`] + * + * This can be used to track which request this event corresponds to. + * + * [`LSPS1ClientHandler::request_supported_options`]: crate::lsps1::client::LSPS1ClientHandler::request_supported_options + */ + struct LDKLSPSRequestId request_id; + /** + * The node id of the LSP that provided this response. + */ + struct LDKPublicKey counterparty_node_id; + /** + * The error that was returned. + */ + struct LDKLSPSResponseError error; +} LDKLSPS1ClientEvent_LDKSupportedOptionsRequestFailed_Body; -extern const uint8_t MAX_PATH_LENGTH_ESTIMATE; +typedef struct LDKLSPS1ClientEvent_LDKOrderCreated_Body { + /** + * The identifier of the issued bLIP-51 / LSPS1 `create_order` request, as returned by + * [`LSPS1ClientHandler::create_order`] + * + * This can be used to track which request this event corresponds to. + * + * [`LSPS1ClientHandler::create_order`]: crate::lsps1::client::LSPS1ClientHandler::create_order + */ + struct LDKLSPSRequestId request_id; + /** + * The node id of the LSP. + */ + struct LDKPublicKey counterparty_node_id; + /** + * The id of the channel order. + */ + struct LDKLSPS1OrderId order_id; + /** + * The order created by client and approved by LSP. + */ + struct LDKLSPS1OrderParams order; + /** + * The details regarding payment of the order + */ + struct LDKLSPS1PaymentInfo payment; + /** + * The details regarding state of the channel ordered. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKLSPS1ChannelInfo channel; +} LDKLSPS1ClientEvent_LDKOrderCreated_Body; -extern const uint64_t MAX_TIMESTAMP; +typedef struct LDKLSPS1ClientEvent_LDKOrderStatus_Body { + /** + * The identifier of the issued bLIP-51 / LSPS1 `get_order` request, as returned by + * [`LSPS1ClientHandler::check_order_status`] + * + * This can be used to track which request this event corresponds to. + * + * [`LSPS1ClientHandler::check_order_status`]: crate::lsps1::client::LSPS1ClientHandler::check_order_status + */ + struct LDKLSPSRequestId request_id; + /** + * The node id of the LSP. + */ + struct LDKPublicKey counterparty_node_id; + /** + * The id of the channel order. + */ + struct LDKLSPS1OrderId order_id; + /** + * The order created by client and approved by LSP. + */ + struct LDKLSPS1OrderParams order; + /** + * The details regarding payment of the order + */ + struct LDKLSPS1PaymentInfo payment; + /** + * The details regarding state of the channel ordered. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKLSPS1ChannelInfo channel; +} LDKLSPS1ClientEvent_LDKOrderStatus_Body; -extern const uint64_t DEFAULT_EXPIRY_TIME; +typedef struct LDKLSPS1ClientEvent_LDKOrderRequestFailed_Body { + /** + * The identifier of the issued LSPS1 `create_order` or `get_order` request, as returned by + * [`LSPS1ClientHandler::create_order`] or [`LSPS1ClientHandler::check_order_status`]. + * + * This can be used to track which request this event corresponds to. + * + * [`LSPS1ClientHandler::create_order`]: crate::lsps1::client::LSPS1ClientHandler::create_order + * [`LSPS1ClientHandler::check_order_status`]: crate::lsps1::client::LSPS1ClientHandler::check_order_status + */ + struct LDKLSPSRequestId request_id; + /** + * The node id of the LSP. + */ + struct LDKPublicKey counterparty_node_id; + /** + * The error that was returned. + */ + struct LDKLSPSResponseError error; +} LDKLSPS1ClientEvent_LDKOrderRequestFailed_Body; -extern const uint64_t DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA; +typedef struct MUST_USE_STRUCT LDKLSPS1ClientEvent { + LDKLSPS1ClientEvent_Tag tag; + union { + LDKLSPS1ClientEvent_LDKSupportedOptionsReady_Body supported_options_ready; + LDKLSPS1ClientEvent_LDKSupportedOptionsRequestFailed_Body supported_options_request_failed; + LDKLSPS1ClientEvent_LDKOrderCreated_Body order_created; + LDKLSPS1ClientEvent_LDKOrderStatus_Body order_status; + LDKLSPS1ClientEvent_LDKOrderRequestFailed_Body order_request_failed; + }; +} LDKLSPS1ClientEvent; -extern const uint8_t TAG_PAYMENT_HASH; +/** + * An event which an LSPS2 client should take some action in response to. + */ +typedef enum LDKLSPS2ClientEvent_Tag { + /** + * Information from the LSP about their current fee rates and channel parameters. + * + * You must call [`LSPS2ClientHandler::select_opening_params`] with the fee parameter + * you want to use if you wish to proceed opening a channel. + * + * [`LSPS2ClientHandler::select_opening_params`]: crate::lsps2::client::LSPS2ClientHandler::select_opening_params + */ + LDKLSPS2ClientEvent_OpeningParametersReady, + /** + * Provides the necessary information to generate a payable invoice that then may be given to + * the payer. + * + * When the invoice is paid, the LSP will open a channel with the previously agreed upon + * parameters to you. + */ + LDKLSPS2ClientEvent_InvoiceParametersReady, + /** + * Must be last for serialization purposes + */ + LDKLSPS2ClientEvent_Sentinel, +} LDKLSPS2ClientEvent_Tag; -extern const uint8_t TAG_DESCRIPTION; +typedef struct LDKLSPS2ClientEvent_LDKOpeningParametersReady_Body { + /** + * The identifier of the issued bLIP-52 / LSPS2 `get_info` request, as returned by + * [`LSPS2ClientHandler::request_opening_params`] + * + * This can be used to track which request this event corresponds to. + * + * [`LSPS2ClientHandler::request_opening_params`]: crate::lsps2::client::LSPS2ClientHandler::request_opening_params + */ + struct LDKLSPSRequestId request_id; + /** + * The node id of the LSP that provided this response. + */ + struct LDKPublicKey counterparty_node_id; + /** + * The menu of fee parameters the LSP is offering at this time. + * You must select one of these if you wish to proceed. + */ + struct LDKCVec_LSPS2OpeningFeeParamsZ opening_fee_params_menu; +} LDKLSPS2ClientEvent_LDKOpeningParametersReady_Body; -extern const uint8_t TAG_PAYEE_PUB_KEY; +typedef struct LDKLSPS2ClientEvent_LDKInvoiceParametersReady_Body { + /** + * The identifier of the issued bLIP-52 / LSPS2 `buy` request, as returned by + * [`LSPS2ClientHandler::select_opening_params`]. + * + * This can be used to track which request this event corresponds to. + * + * [`LSPS2ClientHandler::select_opening_params`]: crate::lsps2::client::LSPS2ClientHandler::select_opening_params + */ + struct LDKLSPSRequestId request_id; + /** + * The node id of the LSP. + */ + struct LDKPublicKey counterparty_node_id; + /** + * The intercept short channel id to use in the route hint. + */ + uint64_t intercept_scid; + /** + * The `cltv_expiry_delta` to use in the route hint. + */ + uint32_t cltv_expiry_delta; + /** + * The initial payment size you specified. + */ + struct LDKCOption_u64Z payment_size_msat; +} LDKLSPS2ClientEvent_LDKInvoiceParametersReady_Body; -extern const uint8_t TAG_DESCRIPTION_HASH; +typedef struct MUST_USE_STRUCT LDKLSPS2ClientEvent { + LDKLSPS2ClientEvent_Tag tag; + union { + LDKLSPS2ClientEvent_LDKOpeningParametersReady_Body opening_parameters_ready; + LDKLSPS2ClientEvent_LDKInvoiceParametersReady_Body invoice_parameters_ready; + }; +} LDKLSPS2ClientEvent; -extern const uint8_t TAG_EXPIRY_TIME; +/** + * An event which an bLIP-52 / LSPS2 server should take some action in response to. + */ +typedef enum LDKLSPS2ServiceEvent_Tag { + /** + * A request from a client for information about JIT Channel parameters. + * + * You must calculate the parameters for this client and pass them to + * [`LSPS2ServiceHandler::opening_fee_params_generated`]. + * + * If an unrecognized or stale token is provided you can use + * `[LSPS2ServiceHandler::invalid_token_provided`] to error the request. + * + * [`LSPS2ServiceHandler::opening_fee_params_generated`]: crate::lsps2::service::LSPS2ServiceHandler::opening_fee_params_generated + * [`LSPS2ServiceHandler::invalid_token_provided`]: crate::lsps2::service::LSPS2ServiceHandler::invalid_token_provided + */ + LDKLSPS2ServiceEvent_GetInfo, + /** + * A client has selected a opening fee parameter to use and would like to + * purchase a channel with an optional initial payment size. + * + * If `payment_size_msat` is [`Option::Some`] then the payer is allowed to use MPP. + * If `payment_size_msat` is [`Option::None`] then the payer cannot use MPP. + * + * You must generate an intercept scid and `cltv_expiry_delta` for them to use + * and call [`LSPS2ServiceHandler::invoice_parameters_generated`]. + * + * [`LSPS2ServiceHandler::invoice_parameters_generated`]: crate::lsps2::service::LSPS2ServiceHandler::invoice_parameters_generated + */ + LDKLSPS2ServiceEvent_BuyRequest, + /** + * You should open a channel using [`ChannelManager::create_channel`]. + * + * [`ChannelManager::create_channel`]: lightning::ln::channelmanager::ChannelManager::create_channel + */ + LDKLSPS2ServiceEvent_OpenChannel, + /** + * Must be last for serialization purposes + */ + LDKLSPS2ServiceEvent_Sentinel, +} LDKLSPS2ServiceEvent_Tag; -extern const uint8_t TAG_MIN_FINAL_CLTV_EXPIRY_DELTA; +typedef struct LDKLSPS2ServiceEvent_LDKGetInfo_Body { + /** + * An identifier that must be passed to [`LSPS2ServiceHandler::opening_fee_params_generated`]. + * + * [`LSPS2ServiceHandler::opening_fee_params_generated`]: crate::lsps2::service::LSPS2ServiceHandler::opening_fee_params_generated + */ + struct LDKLSPSRequestId request_id; + /** + * The node id of the client making the information request. + */ + struct LDKPublicKey counterparty_node_id; + /** + * An optional token that can be used as an API key, coupon code, etc. + */ + struct LDKCOption_StrZ token; +} LDKLSPS2ServiceEvent_LDKGetInfo_Body; -extern const uint8_t TAG_FALLBACK; +typedef struct LDKLSPS2ServiceEvent_LDKBuyRequest_Body { + /** + * An identifier that must be passed into [`LSPS2ServiceHandler::invoice_parameters_generated`]. + * + * [`LSPS2ServiceHandler::invoice_parameters_generated`]: crate::lsps2::service::LSPS2ServiceHandler::invoice_parameters_generated + */ + struct LDKLSPSRequestId request_id; + /** + * The client node id that is making this request. + */ + struct LDKPublicKey counterparty_node_id; + /** + * The channel parameters they have selected. + */ + struct LDKLSPS2OpeningFeeParams opening_fee_params; + /** + * The size of the initial payment they would like to receive. + */ + struct LDKCOption_u64Z payment_size_msat; +} LDKLSPS2ServiceEvent_LDKBuyRequest_Body; -extern const uint8_t TAG_PRIVATE_ROUTE; +typedef struct LDKLSPS2ServiceEvent_LDKOpenChannel_Body { + /** + * The node to open channel with. + */ + struct LDKPublicKey their_network_key; + /** + * The amount to forward after fees. + */ + uint64_t amt_to_forward_msat; + /** + * The fee earned for opening the channel. + */ + uint64_t opening_fee_msat; + /** + * A user specified id used to track channel open. + */ + struct LDKU128 user_channel_id; + /** + * The intercept short channel id to use in the route hint. + */ + uint64_t intercept_scid; +} LDKLSPS2ServiceEvent_LDKOpenChannel_Body; -extern const uint8_t TAG_PAYMENT_SECRET; +typedef struct MUST_USE_STRUCT LDKLSPS2ServiceEvent { + LDKLSPS2ServiceEvent_Tag tag; + union { + LDKLSPS2ServiceEvent_LDKGetInfo_Body get_info; + LDKLSPS2ServiceEvent_LDKBuyRequest_Body buy_request; + LDKLSPS2ServiceEvent_LDKOpenChannel_Body open_channel; + }; +} LDKLSPS2ServiceEvent; -extern const uint8_t TAG_PAYMENT_METADATA; +/** + * An event which you should probably take some action in response to. + */ +typedef enum LDKLiquidityEvent_Tag { + /** + * An LSPS0 client event. + */ + LDKLiquidityEvent_LSPS0Client, + /** + * An LSPS1 (Channel Request) client event. + */ + LDKLiquidityEvent_LSPS1Client, + /** + * An LSPS2 (JIT Channel) client event. + */ + LDKLiquidityEvent_LSPS2Client, + /** + * An LSPS2 (JIT Channel) server event. + */ + LDKLiquidityEvent_LSPS2Service, + /** + * Must be last for serialization purposes + */ + LDKLiquidityEvent_Sentinel, +} LDKLiquidityEvent_Tag; -extern const uint8_t TAG_FEATURES; +typedef struct MUST_USE_STRUCT LDKLiquidityEvent { + LDKLiquidityEvent_Tag tag; + union { + struct { + struct LDKLSPS0ClientEvent lsps0_client; + }; + struct { + struct LDKLSPS1ClientEvent lsps1_client; + }; + struct { + struct LDKLSPS2ClientEvent lsps2_client; + }; + struct { + struct LDKLSPS2ServiceEvent lsps2_service; + }; + }; +} LDKLiquidityEvent; -struct LDKStr _ldk_get_compiled_version(void); -struct LDKStr _ldk_c_bindings_get_compiled_version(void); /** - * Gets the 128-bit integer, as 16 little-endian bytes + * A message handler capable of sending and handling bLIP-50 / LSPS0 messages. */ -struct LDKSixteenBytes U128_le_bytes(struct LDKU128 val); +typedef struct MUST_USE_STRUCT LDKLSPS0ClientHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS0ClientHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS0ClientHandler; + -/** - * Constructs a new U128 from 16 little-endian bytes - */ -struct LDKU128 U128_new(struct LDKSixteenBytes le_bytes); /** - * Constructs a new WitnessProgram given a version and program bytes. + * A `list_protocols` request. * - * The program MUST be at least 2 bytes and no longer than 40 bytes long. - * Further, if the version is 0, the program MUST be either exactly 20 or exactly 32 bytes long. + * Please refer to the [bLIP-50 / LSPS0 + * specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) + * for more information. */ -struct LDKWitnessProgram WitnessProgram_new(struct LDKWitnessVersion version, struct LDKCVec_u8Z program); +typedef struct MUST_USE_STRUCT LDKLSPS0ListProtocolsRequest { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS0ListProtocolsRequest *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS0ListProtocolsRequest; -/** - * Gets the `WitnessVersion` of the given `WitnessProgram` - */ -struct LDKWitnessVersion WitnessProgram_get_version(const struct LDKWitnessProgram *NONNULL_PTR prog); -/** - * Gets the witness program bytes of the given `WitnessProgram` - */ -struct LDKu8slice WitnessProgram_get_program(const struct LDKWitnessProgram *NONNULL_PTR prog); /** - * Creates a new WitnessProgram which has the same data as `orig` + * A response to a `list_protocols` request. + * + * Please refer to the [bLIP-50 / LSPS0 + * specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) + * for more information. */ -struct LDKWitnessProgram WitnessProgram_clone(const struct LDKWitnessProgram *NONNULL_PTR orig); +typedef struct MUST_USE_STRUCT LDKLSPS0ListProtocolsResponse { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS0ListProtocolsResponse *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS0ListProtocolsResponse; /** - * Releases any memory held by the given `WitnessProgram` (which is currently none) + * An bLIP-50 / LSPS0 protocol request. + * + * Please refer to the [bLIP-50 / LSPS0 + * specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) + * for more information. */ -void WitnessProgram_free(struct LDKWitnessProgram o); +typedef enum LDKLSPS0Request_Tag { + /** + * A request calling `list_protocols`. + */ + LDKLSPS0Request_ListProtocols, + /** + * Must be last for serialization purposes + */ + LDKLSPS0Request_Sentinel, +} LDKLSPS0Request_Tag; -/** - * Convenience function for constructing a new BigEndianScalar - */ -struct LDKBigEndianScalar BigEndianScalar_new(struct LDKThirtyTwoBytes big_endian_bytes); +typedef struct MUST_USE_STRUCT LDKLSPS0Request { + LDKLSPS0Request_Tag tag; + union { + struct { + struct LDKLSPS0ListProtocolsRequest list_protocols; + }; + }; +} LDKLSPS0Request; /** - * Creates a new BigEndianScalar which has the same data as `orig` + * An bLIP-50 / LSPS0 protocol request. + * + * Please refer to the [bLIP-50 / LSPS0 + * specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) + * for more information. */ -struct LDKBigEndianScalar BigEndianScalar_clone(const struct LDKBigEndianScalar *NONNULL_PTR orig); +typedef enum LDKLSPS0Response_Tag { + /** + * A response to a `list_protocols` request. + */ + LDKLSPS0Response_ListProtocols, + /** + * An error response to a `list_protocols` request. + */ + LDKLSPS0Response_ListProtocolsError, + /** + * Must be last for serialization purposes + */ + LDKLSPS0Response_Sentinel, +} LDKLSPS0Response_Tag; -/** - * Creates a new Bech32Error which has the same data as `orig` - */ -struct LDKBech32Error Bech32Error_clone(const struct LDKBech32Error *NONNULL_PTR orig); +typedef struct MUST_USE_STRUCT LDKLSPS0Response { + LDKLSPS0Response_Tag tag; + union { + struct { + struct LDKLSPS0ListProtocolsResponse list_protocols; + }; + struct { + struct LDKLSPSResponseError list_protocols_error; + }; + }; +} LDKLSPS0Response; /** - * Releases any memory held by the given `Bech32Error` (which is currently none) + * An bLIP-50 / LSPS0 protocol message. + * + * Please refer to the [bLIP-50 / LSPS0 + * specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) + * for more information. */ -void Bech32Error_free(struct LDKBech32Error o); +typedef enum LDKLSPS0Message_Tag { + /** + * A request variant. + */ + LDKLSPS0Message_Request, + /** + * A response variant. + */ + LDKLSPS0Message_Response, + /** + * Must be last for serialization purposes + */ + LDKLSPS0Message_Sentinel, +} LDKLSPS0Message_Tag; -/** - * Frees the data buffer, if data_is_owned is set and datalen > 0. - */ -void Transaction_free(struct LDKTransaction _res); +typedef struct LDKLSPS0Message_LDKRequest_Body { + struct LDKLSPSRequestId _0; + struct LDKLSPS0Request _1; +} LDKLSPS0Message_LDKRequest_Body; -/** - * Creates a new Witness which has the same data as `orig` but with a new buffer. - */ -struct LDKWitness Witness_clone(const struct LDKWitness *NONNULL_PTR orig); +typedef struct LDKLSPS0Message_LDKResponse_Body { + struct LDKLSPSRequestId _0; + struct LDKLSPS0Response _1; +} LDKLSPS0Message_LDKResponse_Body; -/** - * Frees the data pointed to by data - */ -void Witness_free(struct LDKWitness _res); +typedef struct MUST_USE_STRUCT LDKLSPS0Message { + LDKLSPS0Message_Tag tag; + union { + LDKLSPS0Message_LDKRequest_Body request; + LDKLSPS0Message_LDKResponse_Body response; + }; +} LDKLSPS0Message; -/** - * Convenience function for constructing a new TxIn - */ -struct LDKTxIn TxIn_new(struct LDKWitness witness, struct LDKCVec_u8Z script_sig, uint32_t sequence, struct LDKThirtyTwoBytes previous_txid, uint32_t previous_vout); -/** - * Gets the `witness` in the given `TxIn`. - */ -struct LDKWitness TxIn_get_witness(const struct LDKTxIn *NONNULL_PTR txin); /** - * Gets the `script_sig` in the given `TxIn`. + * A request made to an LSP to retrieve the supported options. + * + * Please refer to the [bLIP-51 / LSPS1 + * specification](https://github.com/lightning/blips/blob/master/blip-0051.md#1-lsps1get_info) for + * more information. */ -struct LDKu8slice TxIn_get_script_sig(const struct LDKTxIn *NONNULL_PTR txin); +typedef struct MUST_USE_STRUCT LDKLSPS1GetInfoRequest { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1GetInfoRequest *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1GetInfoRequest; -/** - * Gets the `sequence` in the given `TxIn`. - */ -uint32_t TxIn_get_sequence(const struct LDKTxIn *NONNULL_PTR txin); -/** - * Gets the previous outpoint txid in the given `TxIn`. - */ -struct LDKThirtyTwoBytes TxIn_get_previous_txid(const struct LDKTxIn *NONNULL_PTR txin); /** - * Gets the previout outpoint index in the given `TxIn`. + * A request made to an LSP to create an order. + * + * Please refer to the [bLIP-51 / LSPS1 + * specification](https://github.com/lightning/blips/blob/master/blip-0051.md#2-lsps1create_order) + * for more information. */ -uint32_t TxIn_get_previous_vout(const struct LDKTxIn *NONNULL_PTR txin); +typedef struct MUST_USE_STRUCT LDKLSPS1CreateOrderRequest { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1CreateOrderRequest *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1CreateOrderRequest; + + /** - * Frees the witness and script_sig in a TxIn + * A request made to an LSP to retrieve information about an previously made order. + * + * Please refer to the [bLIP-51 / LSPS1 + * specification](https://github.com/lightning/blips/blob/master/blip-0051.md#21-lsps1get_order) + * for more information. */ -void TxIn_free(struct LDKTxIn _res); +typedef struct MUST_USE_STRUCT LDKLSPS1GetOrderRequest { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1GetOrderRequest *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1GetOrderRequest; /** - * Convenience function for constructing a new TxOut + * An enum that captures all the valid JSON-RPC requests in the bLIP-51 / LSPS1 protocol. */ -struct LDKTxOut TxOut_new(struct LDKCVec_u8Z script_pubkey, uint64_t value); +typedef enum LDKLSPS1Request_Tag { + /** + * A request to learn about the options supported by the LSP. + */ + LDKLSPS1Request_GetInfo, + /** + * A request to create a channel order. + */ + LDKLSPS1Request_CreateOrder, + /** + * A request to query a previously created channel order. + */ + LDKLSPS1Request_GetOrder, + /** + * Must be last for serialization purposes + */ + LDKLSPS1Request_Sentinel, +} LDKLSPS1Request_Tag; -/** - * Gets the `script_pubkey` in the given `TxOut`. - */ -struct LDKu8slice TxOut_get_script_pubkey(const struct LDKTxOut *NONNULL_PTR txout); +typedef struct MUST_USE_STRUCT LDKLSPS1Request { + LDKLSPS1Request_Tag tag; + union { + struct { + struct LDKLSPS1GetInfoRequest get_info; + }; + struct { + struct LDKLSPS1CreateOrderRequest create_order; + }; + struct { + struct LDKLSPS1GetOrderRequest get_order; + }; + }; +} LDKLSPS1Request; -/** - * Gets the value in the given `TxOut`. - */ -uint64_t TxOut_get_value(const struct LDKTxOut *NONNULL_PTR txout); -/** - * Frees the data pointed to by script_pubkey. - */ -void TxOut_free(struct LDKTxOut _res); /** - * Creates a new TxOut which has the same data as `orig` but with a new script buffer. + * A response to a [`LSPS1GetInfoRequest`]. */ -struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig); +typedef struct MUST_USE_STRUCT LDKLSPS1GetInfoResponse { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1GetInfoResponse *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1GetInfoResponse; -/** - * Frees the data buffer, if chars_is_owned is set and len > 0. - */ -void Str_free(struct LDKStr _res); -#if defined(LDK_DEBUG_BUILD) -/** - * This function exists for memory safety testing purposes. It should never be used in production - * code - */ -const void *__unmangle_inner_ptr(const void *ptr); -#endif /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * A response to a [`LSPS1CreateOrderRequest`]. */ -void CVec_u8Z_free(struct LDKCVec_u8Z _res); +typedef struct MUST_USE_STRUCT LDKLSPS1CreateOrderResponse { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1CreateOrderResponse *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1CreateOrderResponse; /** - * Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ in the success state. + * An enum that captures all the valid JSON-RPC responses in the bLIP-51 / LSPS1 protocol. */ -struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_ok(struct LDKRefundMaybeWithDerivedMetadataBuilder o); +typedef enum LDKLSPS1Response_Tag { + /** + * A successful response to a [`LSPS1GetInfoRequest`]. + */ + LDKLSPS1Response_GetInfo, + /** + * An error response to a [`LSPS1GetInfoRequest`]. + */ + LDKLSPS1Response_GetInfoError, + /** + * A successful response to a [`LSPS1CreateOrderRequest`]. + */ + LDKLSPS1Response_CreateOrder, + /** + * An error response to a [`LSPS1CreateOrderRequest`]. + */ + LDKLSPS1Response_CreateOrderError, + /** + * A successful response to a [`LSPS1GetOrderRequest`]. + */ + LDKLSPS1Response_GetOrder, + /** + * An error response to a [`LSPS1GetOrderRequest`]. + */ + LDKLSPS1Response_GetOrderError, + /** + * Must be last for serialization purposes + */ + LDKLSPS1Response_Sentinel, +} LDKLSPS1Response_Tag; -/** - * Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ in the error state. - */ -struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); +typedef struct MUST_USE_STRUCT LDKLSPS1Response { + LDKLSPS1Response_Tag tag; + union { + struct { + struct LDKLSPS1GetInfoResponse get_info; + }; + struct { + struct LDKLSPSResponseError get_info_error; + }; + struct { + struct LDKLSPS1CreateOrderResponse create_order; + }; + struct { + struct LDKLSPSResponseError create_order_error; + }; + struct { + struct LDKLSPS1CreateOrderResponse get_order; + }; + struct { + struct LDKLSPSResponseError get_order_error; + }; + }; +} LDKLSPS1Response; /** - * Checks if the given object is currently in the success state + * An enum that captures all valid JSON-RPC messages in the bLIP-51 / LSPS1 protocol. */ -bool CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_is_ok(const struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ *NONNULL_PTR o); +typedef enum LDKLSPS1Message_Tag { + /** + * An LSPS1 JSON-RPC request. + */ + LDKLSPS1Message_Request, + /** + * An LSPS1 JSON-RPC response. + */ + LDKLSPS1Message_Response, + /** + * Must be last for serialization purposes + */ + LDKLSPS1Message_Sentinel, +} LDKLSPS1Message_Tag; -/** - * Frees any resources used by the CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ. - */ -void CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_free(struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ _res); +typedef struct LDKLSPS1Message_LDKRequest_Body { + struct LDKLSPSRequestId _0; + struct LDKLSPS1Request _1; +} LDKLSPS1Message_LDKRequest_Body; -/** - * Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_clone(const struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ *NONNULL_PTR orig); +typedef struct LDKLSPS1Message_LDKResponse_Body { + struct LDKLSPSRequestId _0; + struct LDKLSPS1Response _1; +} LDKLSPS1Message_LDKResponse_Body; -/** - * Creates a new CResult_RefundBolt12SemanticErrorZ in the success state. - */ -struct LDKCResult_RefundBolt12SemanticErrorZ CResult_RefundBolt12SemanticErrorZ_ok(struct LDKRefund o); +typedef struct MUST_USE_STRUCT LDKLSPS1Message { + LDKLSPS1Message_Tag tag; + union { + LDKLSPS1Message_LDKRequest_Body request; + LDKLSPS1Message_LDKResponse_Body response; + }; +} LDKLSPS1Message; -/** - * Creates a new CResult_RefundBolt12SemanticErrorZ in the error state. - */ -struct LDKCResult_RefundBolt12SemanticErrorZ CResult_RefundBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); -/** - * Checks if the given object is currently in the success state - */ -bool CResult_RefundBolt12SemanticErrorZ_is_ok(const struct LDKCResult_RefundBolt12SemanticErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RefundBolt12SemanticErrorZ. + * A request made to an LSP to learn their current channel fees and parameters. */ -void CResult_RefundBolt12SemanticErrorZ_free(struct LDKCResult_RefundBolt12SemanticErrorZ _res); +typedef struct MUST_USE_STRUCT LDKLSPS2GetInfoRequest { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS2GetInfoRequest *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS2GetInfoRequest; -/** - * Creates a new CResult_RefundBolt12SemanticErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_RefundBolt12SemanticErrorZ CResult_RefundBolt12SemanticErrorZ_clone(const struct LDKCResult_RefundBolt12SemanticErrorZ *NONNULL_PTR orig); -/** - * Constructs a new COption_u64Z containing a u64 - */ -struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); /** - * Constructs a new COption_u64Z containing nothing + * A request to buy a JIT channel. */ -struct LDKCOption_u64Z COption_u64Z_none(void); +typedef struct MUST_USE_STRUCT LDKLSPS2BuyRequest { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS2BuyRequest *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS2BuyRequest; /** - * Frees any resources associated with the u64, if we are in the Some state + * An enum that captures all the valid JSON-RPC requests in the bLIP-52 / LSPS2 protocol. */ -void COption_u64Z_free(struct LDKCOption_u64Z _res); +typedef enum LDKLSPS2Request_Tag { + /** + * A request to learn an LSP's channel fees and parameters. + */ + LDKLSPS2Request_GetInfo, + /** + * A request to buy a JIT channel from an LSP. + */ + LDKLSPS2Request_Buy, + /** + * Must be last for serialization purposes + */ + LDKLSPS2Request_Sentinel, +} LDKLSPS2Request_Tag; -/** - * Creates a new COption_u64Z which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); +typedef struct MUST_USE_STRUCT LDKLSPS2Request { + LDKLSPS2Request_Tag tag; + union { + struct { + struct LDKLSPS2GetInfoRequest get_info; + }; + struct { + struct LDKLSPS2BuyRequest buy; + }; + }; +} LDKLSPS2Request; -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_BlindedMessagePathZ_free(struct LDKCVec_BlindedMessagePathZ _res); -/** - * Creates a new CResult_RefundDecodeErrorZ in the success state. - */ -struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_ok(struct LDKRefund o); /** - * Creates a new CResult_RefundDecodeErrorZ in the error state. + * A response to a [`LSPS2GetInfoRequest`] */ -struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_err(struct LDKDecodeError e); +typedef struct MUST_USE_STRUCT LDKLSPS2GetInfoResponse { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS2GetInfoResponse *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS2GetInfoResponse; -/** - * Checks if the given object is currently in the success state - */ -bool CResult_RefundDecodeErrorZ_is_ok(const struct LDKCResult_RefundDecodeErrorZ *NONNULL_PTR o); -/** - * Frees any resources used by the CResult_RefundDecodeErrorZ. - */ -void CResult_RefundDecodeErrorZ_free(struct LDKCResult_RefundDecodeErrorZ _res); /** - * Creates a new CResult_RefundDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * A response to a [`LSPS2BuyRequest`]. + * + * Includes information needed to construct an invoice. */ -struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_clone(const struct LDKCResult_RefundDecodeErrorZ *NONNULL_PTR orig); +typedef struct MUST_USE_STRUCT LDKLSPS2BuyResponse { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS2BuyResponse *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS2BuyResponse; /** - * Creates a new CResult_RefundBolt12ParseErrorZ in the success state. + * An enum that captures all the valid JSON-RPC responses in the bLIP-52 / LSPS2 protocol. */ -struct LDKCResult_RefundBolt12ParseErrorZ CResult_RefundBolt12ParseErrorZ_ok(struct LDKRefund o); +typedef enum LDKLSPS2Response_Tag { + /** + * A successful response to a [`LSPS2Request::GetInfo`] request. + */ + LDKLSPS2Response_GetInfo, + /** + * An error response to a [`LSPS2Request::GetInfo`] request. + */ + LDKLSPS2Response_GetInfoError, + /** + * A successful response to a [`LSPS2Request::Buy`] request. + */ + LDKLSPS2Response_Buy, + /** + * An error response to a [`LSPS2Request::Buy`] request. + */ + LDKLSPS2Response_BuyError, + /** + * Must be last for serialization purposes + */ + LDKLSPS2Response_Sentinel, +} LDKLSPS2Response_Tag; -/** - * Creates a new CResult_RefundBolt12ParseErrorZ in the error state. - */ -struct LDKCResult_RefundBolt12ParseErrorZ CResult_RefundBolt12ParseErrorZ_err(struct LDKBolt12ParseError e); +typedef struct MUST_USE_STRUCT LDKLSPS2Response { + LDKLSPS2Response_Tag tag; + union { + struct { + struct LDKLSPS2GetInfoResponse get_info; + }; + struct { + struct LDKLSPSResponseError get_info_error; + }; + struct { + struct LDKLSPS2BuyResponse buy; + }; + struct { + struct LDKLSPSResponseError buy_error; + }; + }; +} LDKLSPS2Response; /** - * Checks if the given object is currently in the success state + * An enum that captures all valid JSON-RPC messages in the bLIP-52 / LSPS2 protocol. */ -bool CResult_RefundBolt12ParseErrorZ_is_ok(const struct LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR o); +typedef enum LDKLSPS2Message_Tag { + /** + * An LSPS2 JSON-RPC request. + */ + LDKLSPS2Message_Request, + /** + * An LSPS2 JSON-RPC response. + */ + LDKLSPS2Message_Response, + /** + * Must be last for serialization purposes + */ + LDKLSPS2Message_Sentinel, +} LDKLSPS2Message_Tag; -/** - * Frees any resources used by the CResult_RefundBolt12ParseErrorZ. - */ -void CResult_RefundBolt12ParseErrorZ_free(struct LDKCResult_RefundBolt12ParseErrorZ _res); +typedef struct LDKLSPS2Message_LDKRequest_Body { + struct LDKLSPSRequestId _0; + struct LDKLSPS2Request _1; +} LDKLSPS2Message_LDKRequest_Body; -/** - * Creates a new CResult_RefundBolt12ParseErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_RefundBolt12ParseErrorZ CResult_RefundBolt12ParseErrorZ_clone(const struct LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR orig); +typedef struct LDKLSPS2Message_LDKResponse_Body { + struct LDKLSPSRequestId _0; + struct LDKLSPS2Response _1; +} LDKLSPS2Message_LDKResponse_Body; -/** - * Creates a new CResult_RetryDecodeErrorZ in the success state. - */ -struct LDKCResult_RetryDecodeErrorZ CResult_RetryDecodeErrorZ_ok(struct LDKRetry o); +typedef struct MUST_USE_STRUCT LDKLSPS2Message { + LDKLSPS2Message_Tag tag; + union { + LDKLSPS2Message_LDKRequest_Body request; + LDKLSPS2Message_LDKResponse_Body response; + }; +} LDKLSPS2Message; /** - * Creates a new CResult_RetryDecodeErrorZ in the error state. + * A (de-)serializable LSPS message allowing to be sent over the wire. */ -struct LDKCResult_RetryDecodeErrorZ CResult_RetryDecodeErrorZ_err(struct LDKDecodeError e); +typedef enum LDKLSPSMessage_Tag { + /** + * An invalid variant. + */ + LDKLSPSMessage_Invalid, + /** + * An LSPS0 message. + */ + LDKLSPSMessage_LSPS0, + /** + * An LSPS1 message. + */ + LDKLSPSMessage_LSPS1, + /** + * An LSPS2 message. + */ + LDKLSPSMessage_LSPS2, + /** + * Must be last for serialization purposes + */ + LDKLSPSMessage_Sentinel, +} LDKLSPSMessage_Tag; -/** - * Checks if the given object is currently in the success state - */ -bool CResult_RetryDecodeErrorZ_is_ok(const struct LDKCResult_RetryDecodeErrorZ *NONNULL_PTR o); +typedef struct MUST_USE_STRUCT LDKLSPSMessage { + LDKLSPSMessage_Tag tag; + union { + struct { + struct LDKLSPSResponseError invalid; + }; + struct { + struct LDKLSPS0Message lsps0; + }; + struct { + struct LDKLSPS1Message lsps1; + }; + struct { + struct LDKLSPS2Message lsps2; + }; + }; +} LDKLSPSMessage; -/** - * Frees any resources used by the CResult_RetryDecodeErrorZ. - */ -void CResult_RetryDecodeErrorZ_free(struct LDKCResult_RetryDecodeErrorZ _res); -/** - * Creates a new CResult_RetryDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_RetryDecodeErrorZ CResult_RetryDecodeErrorZ_clone(const struct LDKCResult_RetryDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_ThirtyTwoBytesZ containing a crate::c_types::ThirtyTwoBytes + * The main server-side object allowing to send and receive bLIP-50 / LSPS0 messages. */ -struct LDKCOption_ThirtyTwoBytesZ COption_ThirtyTwoBytesZ_some(struct LDKThirtyTwoBytes o); +typedef struct MUST_USE_STRUCT LDKLSPS0ServiceHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS0ServiceHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS0ServiceHandler; -/** - * Constructs a new COption_ThirtyTwoBytesZ containing nothing - */ -struct LDKCOption_ThirtyTwoBytesZ COption_ThirtyTwoBytesZ_none(void); -/** - * Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state - */ -void COption_ThirtyTwoBytesZ_free(struct LDKCOption_ThirtyTwoBytesZ _res); /** - * Creates a new COption_ThirtyTwoBytesZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Client-side configuration options for bLIP-51 / LSPS1 channel requests. */ -struct LDKCOption_ThirtyTwoBytesZ COption_ThirtyTwoBytesZ_clone(const struct LDKCOption_ThirtyTwoBytesZ *NONNULL_PTR orig); +typedef struct MUST_USE_STRUCT LDKLSPS1ClientConfig { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1ClientConfig *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1ClientConfig; -/** - * Constructs a new COption_CVec_u8ZZ containing a crate::c_types::derived::CVec_u8Z - */ -struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_some(struct LDKCVec_u8Z o); -/** - * Constructs a new COption_CVec_u8ZZ containing nothing - */ -struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_none(void); /** - * Frees any resources associated with the crate::c_types::derived::CVec_u8Z, if we are in the Some state + * The main object allowing to send and receive bLIP-51 / LSPS1 messages. */ -void COption_CVec_u8ZZ_free(struct LDKCOption_CVec_u8ZZ _res); +typedef struct MUST_USE_STRUCT LDKLSPS1ClientHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1ClientHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1ClientHandler; -/** - * Creates a new COption_CVec_u8ZZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_clone(const struct LDKCOption_CVec_u8ZZ *NONNULL_PTR orig); -/** - * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the success state. - */ -struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_ok(struct LDKRecipientOnionFields o); /** - * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the error state. + * A Lightning payment using BOLT 11. */ -struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_err(struct LDKDecodeError e); +typedef struct MUST_USE_STRUCT LDKLSPS1Bolt11PaymentInfo { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1Bolt11PaymentInfo *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1Bolt11PaymentInfo; -/** - * Checks if the given object is currently in the success state - */ -bool CResult_RecipientOnionFieldsDecodeErrorZ_is_ok(const struct LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR o); -/** - * Frees any resources used by the CResult_RecipientOnionFieldsDecodeErrorZ. - */ -void CResult_RecipientOnionFieldsDecodeErrorZ_free(struct LDKCResult_RecipientOnionFieldsDecodeErrorZ _res); /** - * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * An onchain payment. */ -struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_clone(const struct LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR orig); +typedef struct MUST_USE_STRUCT LDKLSPS1OnchainPaymentInfo { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1OnchainPaymentInfo *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1OnchainPaymentInfo; -/** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKC2Tuple_u64CVec_u8ZZ C2Tuple_u64CVec_u8ZZ_clone(const struct LDKC2Tuple_u64CVec_u8ZZ *NONNULL_PTR orig); -/** - * Creates a new C2Tuple_u64CVec_u8ZZ from the contained elements. - */ -struct LDKC2Tuple_u64CVec_u8ZZ C2Tuple_u64CVec_u8ZZ_new(uint64_t a, struct LDKCVec_u8Z b); /** - * Frees any resources used by the C2Tuple_u64CVec_u8ZZ. + * Details regarding a detected on-chain payment. */ -void C2Tuple_u64CVec_u8ZZ_free(struct LDKC2Tuple_u64CVec_u8ZZ _res); +typedef struct MUST_USE_STRUCT LDKLSPS1OnchainPayment { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS1OnchainPayment *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS1OnchainPayment; -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_C2Tuple_u64CVec_u8ZZZ_free(struct LDKCVec_C2Tuple_u64CVec_u8ZZZ _res); -/** - * Creates a new CResult_RecipientOnionFieldsNoneZ in the success state. - */ -struct LDKCResult_RecipientOnionFieldsNoneZ CResult_RecipientOnionFieldsNoneZ_ok(struct LDKRecipientOnionFields o); /** - * Creates a new CResult_RecipientOnionFieldsNoneZ in the error state. + * Client-side configuration options for JIT channels. */ -struct LDKCResult_RecipientOnionFieldsNoneZ CResult_RecipientOnionFieldsNoneZ_err(void); +typedef struct MUST_USE_STRUCT LDKLSPS2ClientConfig { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS2ClientConfig *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS2ClientConfig; -/** - * Checks if the given object is currently in the success state - */ -bool CResult_RecipientOnionFieldsNoneZ_is_ok(const struct LDKCResult_RecipientOnionFieldsNoneZ *NONNULL_PTR o); -/** - * Frees any resources used by the CResult_RecipientOnionFieldsNoneZ. - */ -void CResult_RecipientOnionFieldsNoneZ_free(struct LDKCResult_RecipientOnionFieldsNoneZ _res); /** - * Creates a new CResult_RecipientOnionFieldsNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The main object allowing to send and receive bLIP-52 / LSPS2 messages. + * + * Note that currently only the 'client-trusts-LSP' trust model is supported, i.e., we don't + * provide any additional API guidance to allow withholding the preimage until the channel is + * opened. Please refer to the [`bLIP-52 / LSPS2 specification`] for more information. + * + * [`bLIP-52 / LSPS2 specification`]: https://github.com/lightning/blips/blob/master/blip-0052.md#trust-models */ -struct LDKCResult_RecipientOnionFieldsNoneZ CResult_RecipientOnionFieldsNoneZ_clone(const struct LDKCResult_RecipientOnionFieldsNoneZ *NONNULL_PTR orig); +typedef struct MUST_USE_STRUCT LDKLSPS2ClientHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS2ClientHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS2ClientHandler; -/** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKC2Tuple_DNSResolverMessageResponseInstructionZ C2Tuple_DNSResolverMessageResponseInstructionZ_clone(const struct LDKC2Tuple_DNSResolverMessageResponseInstructionZ *NONNULL_PTR orig); -/** - * Creates a new C2Tuple_DNSResolverMessageResponseInstructionZ from the contained elements. - */ -struct LDKC2Tuple_DNSResolverMessageResponseInstructionZ C2Tuple_DNSResolverMessageResponseInstructionZ_new(struct LDKDNSResolverMessage a, struct LDKResponseInstruction b); /** - * Frees any resources used by the C2Tuple_DNSResolverMessageResponseInstructionZ. + * A newtype that holds a `short_channel_id` in human readable format of BBBxTTTx000. */ -void C2Tuple_DNSResolverMessageResponseInstructionZ_free(struct LDKC2Tuple_DNSResolverMessageResponseInstructionZ _res); +typedef struct MUST_USE_STRUCT LDKLSPS2InterceptScid { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS2InterceptScid *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS2InterceptScid; + + /** - * Constructs a new COption_C2Tuple_DNSResolverMessageResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_DNSResolverMessageResponseInstructionZ + * Server-side configuration options for JIT channels. */ -struct LDKCOption_C2Tuple_DNSResolverMessageResponseInstructionZZ COption_C2Tuple_DNSResolverMessageResponseInstructionZZ_some(struct LDKC2Tuple_DNSResolverMessageResponseInstructionZ o); +typedef struct MUST_USE_STRUCT LDKLSPS2ServiceConfig { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS2ServiceConfig *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS2ServiceConfig; -/** - * Constructs a new COption_C2Tuple_DNSResolverMessageResponseInstructionZZ containing nothing - */ -struct LDKCOption_C2Tuple_DNSResolverMessageResponseInstructionZZ COption_C2Tuple_DNSResolverMessageResponseInstructionZZ_none(void); -/** - * Frees any resources associated with the crate::c_types::derived::C2Tuple_DNSResolverMessageResponseInstructionZ, if we are in the Some state - */ -void COption_C2Tuple_DNSResolverMessageResponseInstructionZZ_free(struct LDKCOption_C2Tuple_DNSResolverMessageResponseInstructionZZ _res); /** - * Creates a new COption_C2Tuple_DNSResolverMessageResponseInstructionZZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The main object allowing to send and receive bLIP-52 / LSPS2 messages. */ -struct LDKCOption_C2Tuple_DNSResolverMessageResponseInstructionZZ COption_C2Tuple_DNSResolverMessageResponseInstructionZZ_clone(const struct LDKCOption_C2Tuple_DNSResolverMessageResponseInstructionZZ *NONNULL_PTR orig); +typedef struct MUST_USE_STRUCT LDKLSPS2ServiceHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLSPS2ServiceHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLSPS2ServiceHandler; + + /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The default [`MessageQueue`] Implementation used by [`LiquidityManager`]. + * + * [`LiquidityManager`]: crate::LiquidityManager */ -struct LDKC2Tuple_DNSResolverMessageMessageSendInstructionsZ C2Tuple_DNSResolverMessageMessageSendInstructionsZ_clone(const struct LDKC2Tuple_DNSResolverMessageMessageSendInstructionsZ *NONNULL_PTR orig); +typedef struct MUST_USE_STRUCT LDKMessageQueue { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMessageQueue *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKMessageQueue; /** - * Creates a new C2Tuple_DNSResolverMessageMessageSendInstructionsZ from the contained elements. + * A callback which will be called to trigger network message processing. + * + * Usually, this should call [`PeerManager::process_events`]. + * + * [`PeerManager::process_events`]: lightning::ln::peer_handler::PeerManager::process_events */ -struct LDKC2Tuple_DNSResolverMessageMessageSendInstructionsZ C2Tuple_DNSResolverMessageMessageSendInstructionsZ_new(struct LDKDNSResolverMessage a, struct LDKMessageSendInstructions b); +typedef struct LDKProcessMessagesCallback { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * The method which is called. + */ + void (*call)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKProcessMessagesCallback; + +extern const uintptr_t MAX_BUF_SIZE; + +extern const uintptr_t KVSTORE_NAMESPACE_KEY_MAX_LEN; + +extern const uint64_t MAX_SCID_BLOCK; + +extern const uint64_t MAX_SCID_TX_INDEX; + +extern const uint64_t MAX_SCID_VOUT_INDEX; + +extern const uint32_t PRUNE_DELAY_BLOCKS; + +extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; + +extern const uint32_t FEERATE_FLOOR_SATS_PER_KW; + +extern const uint32_t ANTI_REORG_DELAY; + +extern const uint32_t ARCHIVAL_DELAY_BLOCKS; + +extern const uint16_t BREAKDOWN_TIMEOUT; + +extern const uint16_t MIN_CLTV_EXPIRY_DELTA; + +extern const uint16_t MIN_FINAL_CLTV_EXPIRY_DELTA; + +extern const uint16_t MAX_HTLCS; + +extern const uintptr_t OFFERED_HTLC_SCRIPT_WEIGHT; + +extern const uintptr_t OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS; + +extern const uintptr_t MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT; + +extern const uint64_t ANCHOR_INPUT_WITNESS_WEIGHT; + +extern const uint64_t HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT; + +extern const uint64_t HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT; + +extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; + +extern const uintptr_t PAYER_NOTE_LIMIT; + +extern const uint64_t UNKNOWN_CHANNEL_CAPACITY_MSAT; + +extern const uint32_t DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA; + +extern const uint8_t DEFAULT_MAX_PATH_COUNT; + +extern const uint8_t MAX_PATH_LENGTH_ESTIMATE; + +extern const uint64_t MAX_TIMESTAMP; + +extern const uint64_t DEFAULT_EXPIRY_TIME; + +extern const uint64_t DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA; + +extern const uintptr_t MAX_LENGTH; + +extern const uint8_t TAG_PAYMENT_HASH; + +extern const uint8_t TAG_DESCRIPTION; + +extern const uint8_t TAG_PAYEE_PUB_KEY; + +extern const uint8_t TAG_DESCRIPTION_HASH; + +extern const uint8_t TAG_EXPIRY_TIME; + +extern const uint8_t TAG_MIN_FINAL_CLTV_EXPIRY_DELTA; + +extern const uint8_t TAG_FALLBACK; + +extern const uint8_t TAG_PRIVATE_ROUTE; + +extern const uint8_t TAG_PAYMENT_SECRET; + +extern const uint8_t TAG_PAYMENT_METADATA; + +extern const uint8_t TAG_FEATURES; + +extern const uintptr_t MAX_EVENT_QUEUE_SIZE; + +extern const uint16_t LSPS_MESSAGE_TYPE_ID; + +struct LDKStr _ldk_get_compiled_version(void); + +struct LDKStr _ldk_c_bindings_get_compiled_version(void); /** - * Frees any resources used by the C2Tuple_DNSResolverMessageMessageSendInstructionsZ. + * Gets the 128-bit integer, as 16 little-endian bytes */ -void C2Tuple_DNSResolverMessageMessageSendInstructionsZ_free(struct LDKC2Tuple_DNSResolverMessageMessageSendInstructionsZ _res); +struct LDKSixteenBytes U128_le_bytes(struct LDKU128 val); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new U128 from 16 little-endian bytes */ -void CVec_C2Tuple_DNSResolverMessageMessageSendInstructionsZZ_free(struct LDKCVec_C2Tuple_DNSResolverMessageMessageSendInstructionsZZ _res); +struct LDKU128 U128_new(struct LDKSixteenBytes le_bytes); /** - * Creates a new CResult_DNSResolverMessageDecodeErrorZ in the success state. + * Constructs a new WitnessProgram given a version and program bytes. + * + * The program MUST be at least 2 bytes and no longer than 40 bytes long. + * Further, if the version is 0, the program MUST be either exactly 20 or exactly 32 bytes long. */ -struct LDKCResult_DNSResolverMessageDecodeErrorZ CResult_DNSResolverMessageDecodeErrorZ_ok(struct LDKDNSResolverMessage o); +struct LDKWitnessProgram WitnessProgram_new(struct LDKWitnessVersion version, struct LDKCVec_u8Z program); /** - * Creates a new CResult_DNSResolverMessageDecodeErrorZ in the error state. + * Gets the `WitnessVersion` of the given `WitnessProgram` */ -struct LDKCResult_DNSResolverMessageDecodeErrorZ CResult_DNSResolverMessageDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKWitnessVersion WitnessProgram_get_version(const struct LDKWitnessProgram *NONNULL_PTR prog); /** - * Checks if the given object is currently in the success state + * Gets the witness program bytes of the given `WitnessProgram` */ -bool CResult_DNSResolverMessageDecodeErrorZ_is_ok(const struct LDKCResult_DNSResolverMessageDecodeErrorZ *NONNULL_PTR o); +struct LDKu8slice WitnessProgram_get_program(const struct LDKWitnessProgram *NONNULL_PTR prog); /** - * Frees any resources used by the CResult_DNSResolverMessageDecodeErrorZ. + * Creates a new WitnessProgram which has the same data as `orig` */ -void CResult_DNSResolverMessageDecodeErrorZ_free(struct LDKCResult_DNSResolverMessageDecodeErrorZ _res); +struct LDKWitnessProgram WitnessProgram_clone(const struct LDKWitnessProgram *NONNULL_PTR orig); /** - * Creates a new CResult_DNSResolverMessageDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Releases any memory held by the given `WitnessProgram` (which is currently none) */ -struct LDKCResult_DNSResolverMessageDecodeErrorZ CResult_DNSResolverMessageDecodeErrorZ_clone(const struct LDKCResult_DNSResolverMessageDecodeErrorZ *NONNULL_PTR orig); +void WitnessProgram_free(struct LDKWitnessProgram o); /** - * Creates a new CResult_HumanReadableNameNoneZ in the success state. + * Gets the string representation of the address in `addr` */ -struct LDKCResult_HumanReadableNameNoneZ CResult_HumanReadableNameNoneZ_ok(struct LDKHumanReadableName o); +struct LDKStr Address_to_string(const struct LDKAddress *NONNULL_PTR addr); /** - * Creates a new CResult_HumanReadableNameNoneZ in the error state. + * Constructs a new `Address` (option) from the given string representation. + * + * Returns `None` only if the address is invalid. */ -struct LDKCResult_HumanReadableNameNoneZ CResult_HumanReadableNameNoneZ_err(void); +struct LDKCOption_AddressZ Address_new(struct LDKStr s); /** - * Checks if the given object is currently in the success state + * Releases any memory held by the given `Address` */ -bool CResult_HumanReadableNameNoneZ_is_ok(const struct LDKCResult_HumanReadableNameNoneZ *NONNULL_PTR o); +void Address_free(struct LDKAddress o); /** - * Frees any resources used by the CResult_HumanReadableNameNoneZ. + * Creates a new Address which has the same data as `orig` */ -void CResult_HumanReadableNameNoneZ_free(struct LDKCResult_HumanReadableNameNoneZ _res); +struct LDKAddress Address_clone(const struct LDKAddress *NONNULL_PTR orig); /** - * Creates a new CResult_HumanReadableNameNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Convenience function for constructing a new BigEndianScalar */ -struct LDKCResult_HumanReadableNameNoneZ CResult_HumanReadableNameNoneZ_clone(const struct LDKCResult_HumanReadableNameNoneZ *NONNULL_PTR orig); +struct LDKBigEndianScalar BigEndianScalar_new(struct LDKThirtyTwoBytes big_endian_bytes); /** - * Creates a new CResult_HumanReadableNameDecodeErrorZ in the success state. + * Creates a new BigEndianScalar which has the same data as `orig` */ -struct LDKCResult_HumanReadableNameDecodeErrorZ CResult_HumanReadableNameDecodeErrorZ_ok(struct LDKHumanReadableName o); +struct LDKBigEndianScalar BigEndianScalar_clone(const struct LDKBigEndianScalar *NONNULL_PTR orig); /** - * Creates a new CResult_HumanReadableNameDecodeErrorZ in the error state. + * Creates a new Bech32Error which has the same data as `orig` */ -struct LDKCResult_HumanReadableNameDecodeErrorZ CResult_HumanReadableNameDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKBech32Error Bech32Error_clone(const struct LDKBech32Error *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Releases any memory held by the given `Bech32Error` (which is currently none) */ -bool CResult_HumanReadableNameDecodeErrorZ_is_ok(const struct LDKCResult_HumanReadableNameDecodeErrorZ *NONNULL_PTR o); +void Bech32Error_free(struct LDKBech32Error o); /** - * Frees any resources used by the CResult_HumanReadableNameDecodeErrorZ. + * Frees the data buffer, if data_is_owned is set and datalen > 0. */ -void CResult_HumanReadableNameDecodeErrorZ_free(struct LDKCResult_HumanReadableNameDecodeErrorZ _res); +void Transaction_free(struct LDKTransaction _res); /** - * Creates a new CResult_HumanReadableNameDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new Witness which has the same data as `orig` but with a new buffer. */ -struct LDKCResult_HumanReadableNameDecodeErrorZ CResult_HumanReadableNameDecodeErrorZ_clone(const struct LDKCResult_HumanReadableNameDecodeErrorZ *NONNULL_PTR orig); +struct LDKWitness Witness_clone(const struct LDKWitness *NONNULL_PTR orig); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the data pointed to by data */ -struct LDKC2Tuple_DNSSECQueryDNSResolverContextZ C2Tuple_DNSSECQueryDNSResolverContextZ_clone(const struct LDKC2Tuple_DNSSECQueryDNSResolverContextZ *NONNULL_PTR orig); +void Witness_free(struct LDKWitness _res); /** - * Creates a new C2Tuple_DNSSECQueryDNSResolverContextZ from the contained elements. + * Convenience function for constructing a new TxIn */ -struct LDKC2Tuple_DNSSECQueryDNSResolverContextZ C2Tuple_DNSSECQueryDNSResolverContextZ_new(struct LDKDNSSECQuery a, struct LDKDNSResolverContext b); +struct LDKTxIn TxIn_new(struct LDKWitness witness, struct LDKCVec_u8Z script_sig, uint32_t sequence, struct LDKThirtyTwoBytes previous_txid, uint32_t previous_vout); /** - * Frees any resources used by the C2Tuple_DNSSECQueryDNSResolverContextZ. + * Gets the `witness` in the given `TxIn`. */ -void C2Tuple_DNSSECQueryDNSResolverContextZ_free(struct LDKC2Tuple_DNSSECQueryDNSResolverContextZ _res); +struct LDKWitness TxIn_get_witness(const struct LDKTxIn *NONNULL_PTR txin); /** - * Creates a new CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ in the success state. + * Gets the `script_sig` in the given `TxIn`. */ -struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ_ok(struct LDKC2Tuple_DNSSECQueryDNSResolverContextZ o); +struct LDKu8slice TxIn_get_script_sig(const struct LDKTxIn *NONNULL_PTR txin); /** - * Creates a new CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ in the error state. + * Gets the `sequence` in the given `TxIn`. */ -struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ_err(void); +uint32_t TxIn_get_sequence(const struct LDKTxIn *NONNULL_PTR txin); /** - * Checks if the given object is currently in the success state + * Gets the previous outpoint txid in the given `TxIn`. */ -bool CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ_is_ok(const struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ *NONNULL_PTR o); +struct LDKThirtyTwoBytes TxIn_get_previous_txid(const struct LDKTxIn *NONNULL_PTR txin); /** - * Frees any resources used by the CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ. + * Gets the previout outpoint index in the given `TxIn`. */ -void CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ_free(struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ _res); +uint32_t TxIn_get_previous_vout(const struct LDKTxIn *NONNULL_PTR txin); /** - * Creates a new CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the witness and script_sig in a TxIn */ -struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ_clone(const struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ *NONNULL_PTR orig); +void TxIn_free(struct LDKTxIn _res); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Convenience function for constructing a new TxOut */ -struct LDKC2Tuple_HumanReadableNameThirtyTwoBytesZ C2Tuple_HumanReadableNameThirtyTwoBytesZ_clone(const struct LDKC2Tuple_HumanReadableNameThirtyTwoBytesZ *NONNULL_PTR orig); +struct LDKTxOut TxOut_new(struct LDKCVec_u8Z script_pubkey, uint64_t value); /** - * Creates a new C2Tuple_HumanReadableNameThirtyTwoBytesZ from the contained elements. + * Gets the `script_pubkey` in the given `TxOut`. */ -struct LDKC2Tuple_HumanReadableNameThirtyTwoBytesZ C2Tuple_HumanReadableNameThirtyTwoBytesZ_new(struct LDKHumanReadableName a, struct LDKThirtyTwoBytes b); +struct LDKu8slice TxOut_get_script_pubkey(const struct LDKTxOut *NONNULL_PTR txout); /** - * Frees any resources used by the C2Tuple_HumanReadableNameThirtyTwoBytesZ. + * Gets the value in the given `TxOut`. */ -void C2Tuple_HumanReadableNameThirtyTwoBytesZ_free(struct LDKC2Tuple_HumanReadableNameThirtyTwoBytesZ _res); +uint64_t TxOut_get_value(const struct LDKTxOut *NONNULL_PTR txout); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees the data pointed to by script_pubkey. */ -void CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZ_free(struct LDKCVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZ _res); +void TxOut_free(struct LDKTxOut _res); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new TxOut which has the same data as `orig` but with a new script buffer. */ -struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ_clone(const struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ *NONNULL_PTR orig); +struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig); /** - * Creates a new C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ from the contained elements. + * Frees the data buffer, if chars_is_owned is set and len > 0. */ -struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ_new(struct LDKCVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZ a, struct LDKOffer b); +void Str_free(struct LDKStr _res); +#if defined(LDK_DEBUG_BUILD) /** - * Frees any resources used by the C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ. + * This function exists for memory safety testing purposes. It should never be used in production + * code */ -void C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ_free(struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ _res); +const void *__unmangle_inner_ptr(const void *ptr); +#endif /** - * Constructs a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ containing a crate::c_types::derived::C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ_some(struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ o); +void CVec_u8Z_free(struct LDKCVec_u8Z _res); /** - * Constructs a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ containing nothing + * Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ in the success state. */ -struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ_none(void); +struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_ok(struct LDKRefundMaybeWithDerivedMetadataBuilder o); /** - * Frees any resources associated with the crate::c_types::derived::C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ, if we are in the Some state + * Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ in the error state. */ -void COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ_free(struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ _res); +struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); /** - * Creates a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if the given object is currently in the success state */ -struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ_clone(const struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ *NONNULL_PTR orig); +bool CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_is_ok(const struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ *NONNULL_PTR o); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ. */ -struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ_clone(const struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ *NONNULL_PTR orig); +void CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_free(struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ _res); /** - * Creates a new C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ from the contained elements. + * Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ_new(struct LDKCVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZ a, struct LDKStr b); +struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_clone(const struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ. + * Creates a new CResult_RefundBolt12SemanticErrorZ in the success state. */ -void C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ_free(struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ _res); +struct LDKCResult_RefundBolt12SemanticErrorZ CResult_RefundBolt12SemanticErrorZ_ok(struct LDKRefund o); /** - * Constructs a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ containing a crate::c_types::derived::C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ + * Creates a new CResult_RefundBolt12SemanticErrorZ in the error state. */ -struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ_some(struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ o); +struct LDKCResult_RefundBolt12SemanticErrorZ CResult_RefundBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); /** - * Constructs a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ_none(void); +bool CResult_RefundBolt12SemanticErrorZ_is_ok(const struct LDKCResult_RefundBolt12SemanticErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::c_types::derived::C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ, if we are in the Some state + * Frees any resources used by the CResult_RefundBolt12SemanticErrorZ. */ -void COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ_free(struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ _res); +void CResult_RefundBolt12SemanticErrorZ_free(struct LDKCResult_RefundBolt12SemanticErrorZ _res); /** - * Creates a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ which has the same data as `orig` + * Creates a new CResult_RefundBolt12SemanticErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ_clone(const struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ *NONNULL_PTR orig); +struct LDKCResult_RefundBolt12SemanticErrorZ CResult_RefundBolt12SemanticErrorZ_clone(const struct LDKCResult_RefundBolt12SemanticErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ in the success state. + * Constructs a new COption_u64Z containing a u64 */ -struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_ok(struct LDKUnsignedBolt12Invoice o); +struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); /** - * Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ in the error state. + * Constructs a new COption_u64Z containing nothing */ -struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); +struct LDKCOption_u64Z COption_u64Z_none(void); /** - * Checks if the given object is currently in the success state + * Frees any resources associated with the u64, if we are in the Some state */ -bool CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_is_ok(const struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR o); +void COption_u64Z_free(struct LDKCOption_u64Z _res); /** - * Frees any resources used by the CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ. + * Creates a new COption_u64Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_free(struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ _res); +struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); /** - * Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_clone(const struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR orig); +void CVec_BlindedMessagePathZ_free(struct LDKCVec_BlindedMessagePathZ _res); /** - * Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ in the success state. + * Creates a new CResult_RefundDecodeErrorZ in the success state. */ -struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ CResult_Bolt12InvoiceBolt12SemanticErrorZ_ok(struct LDKBolt12Invoice o); +struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_ok(struct LDKRefund o); /** - * Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ in the error state. + * Creates a new CResult_RefundDecodeErrorZ in the error state. */ -struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ CResult_Bolt12InvoiceBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); +struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_Bolt12InvoiceBolt12SemanticErrorZ_is_ok(const struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR o); +bool CResult_RefundDecodeErrorZ_is_ok(const struct LDKCResult_RefundDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_Bolt12InvoiceBolt12SemanticErrorZ. + * Frees any resources used by the CResult_RefundDecodeErrorZ. */ -void CResult_Bolt12InvoiceBolt12SemanticErrorZ_free(struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ _res); +void CResult_RefundDecodeErrorZ_free(struct LDKCResult_RefundDecodeErrorZ _res); /** - * Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ which has the same data as `orig` + * Creates a new CResult_RefundDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ CResult_Bolt12InvoiceBolt12SemanticErrorZ_clone(const struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR orig); +struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_clone(const struct LDKCResult_RefundDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SchnorrSignatureNoneZ in the success state. + * Creates a new CResult_RefundBolt12ParseErrorZ in the success state. */ -struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_ok(struct LDKSchnorrSignature o); +struct LDKCResult_RefundBolt12ParseErrorZ CResult_RefundBolt12ParseErrorZ_ok(struct LDKRefund o); /** - * Creates a new CResult_SchnorrSignatureNoneZ in the error state. + * Creates a new CResult_RefundBolt12ParseErrorZ in the error state. */ -struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_err(void); +struct LDKCResult_RefundBolt12ParseErrorZ CResult_RefundBolt12ParseErrorZ_err(struct LDKBolt12ParseError e); /** * Checks if the given object is currently in the success state */ -bool CResult_SchnorrSignatureNoneZ_is_ok(const struct LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR o); +bool CResult_RefundBolt12ParseErrorZ_is_ok(const struct LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_SchnorrSignatureNoneZ. + * Frees any resources used by the CResult_RefundBolt12ParseErrorZ. */ -void CResult_SchnorrSignatureNoneZ_free(struct LDKCResult_SchnorrSignatureNoneZ _res); +void CResult_RefundBolt12ParseErrorZ_free(struct LDKCResult_RefundBolt12ParseErrorZ _res); /** - * Creates a new CResult_SchnorrSignatureNoneZ which has the same data as `orig` + * Creates a new CResult_RefundBolt12ParseErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_clone(const struct LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_BlindedPaymentPathZ_free(struct LDKCVec_BlindedPaymentPathZ _res); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_StrZ_free(struct LDKCVec_StrZ _res); +struct LDKCResult_RefundBolt12ParseErrorZ CResult_RefundBolt12ParseErrorZ_clone(const struct LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_RetryDecodeErrorZ in the success state. */ -void CVec_ThirtyTwoBytesZ_free(struct LDKCVec_ThirtyTwoBytesZ _res); +struct LDKCResult_RetryDecodeErrorZ CResult_RetryDecodeErrorZ_ok(struct LDKRetry o); /** - * Constructs a new COption_CVec_ThirtyTwoBytesZZ containing a crate::c_types::derived::CVec_ThirtyTwoBytesZ + * Creates a new CResult_RetryDecodeErrorZ in the error state. */ -struct LDKCOption_CVec_ThirtyTwoBytesZZ COption_CVec_ThirtyTwoBytesZZ_some(struct LDKCVec_ThirtyTwoBytesZ o); +struct LDKCResult_RetryDecodeErrorZ CResult_RetryDecodeErrorZ_err(struct LDKDecodeError e); /** - * Constructs a new COption_CVec_ThirtyTwoBytesZZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_CVec_ThirtyTwoBytesZZ COption_CVec_ThirtyTwoBytesZZ_none(void); +bool CResult_RetryDecodeErrorZ_is_ok(const struct LDKCResult_RetryDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::c_types::derived::CVec_ThirtyTwoBytesZ, if we are in the Some state + * Frees any resources used by the CResult_RetryDecodeErrorZ. */ -void COption_CVec_ThirtyTwoBytesZZ_free(struct LDKCOption_CVec_ThirtyTwoBytesZZ _res); +void CResult_RetryDecodeErrorZ_free(struct LDKCResult_RetryDecodeErrorZ _res); /** - * Creates a new COption_CVec_ThirtyTwoBytesZZ which has the same data as `orig` + * Creates a new CResult_RetryDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_CVec_ThirtyTwoBytesZZ COption_CVec_ThirtyTwoBytesZZ_clone(const struct LDKCOption_CVec_ThirtyTwoBytesZZ *NONNULL_PTR orig); +struct LDKCResult_RetryDecodeErrorZ CResult_RetryDecodeErrorZ_clone(const struct LDKCResult_RetryDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_AmountZ containing a crate::lightning::offers::offer::Amount + * Constructs a new COption_ThirtyTwoBytesZ containing a crate::c_types::ThirtyTwoBytes */ -struct LDKCOption_AmountZ COption_AmountZ_some(struct LDKAmount o); +struct LDKCOption_ThirtyTwoBytesZ COption_ThirtyTwoBytesZ_some(struct LDKThirtyTwoBytes o); /** - * Constructs a new COption_AmountZ containing nothing + * Constructs a new COption_ThirtyTwoBytesZ containing nothing */ -struct LDKCOption_AmountZ COption_AmountZ_none(void); +struct LDKCOption_ThirtyTwoBytesZ COption_ThirtyTwoBytesZ_none(void); /** - * Frees any resources associated with the crate::lightning::offers::offer::Amount, if we are in the Some state + * Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state */ -void COption_AmountZ_free(struct LDKCOption_AmountZ _res); +void COption_ThirtyTwoBytesZ_free(struct LDKCOption_ThirtyTwoBytesZ _res); /** - * Creates a new COption_AmountZ which has the same data as `orig` + * Creates a new COption_ThirtyTwoBytesZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_AmountZ COption_AmountZ_clone(const struct LDKCOption_AmountZ *NONNULL_PTR orig); +struct LDKCOption_ThirtyTwoBytesZ COption_ThirtyTwoBytesZ_clone(const struct LDKCOption_ThirtyTwoBytesZ *NONNULL_PTR orig); /** - * Constructs a new COption_QuantityZ containing a crate::lightning::offers::offer::Quantity + * Constructs a new COption_CVec_u8ZZ containing a crate::c_types::derived::CVec_u8Z */ -struct LDKCOption_QuantityZ COption_QuantityZ_some(struct LDKQuantity o); +struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_some(struct LDKCVec_u8Z o); /** - * Constructs a new COption_QuantityZ containing nothing + * Constructs a new COption_CVec_u8ZZ containing nothing */ -struct LDKCOption_QuantityZ COption_QuantityZ_none(void); +struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_none(void); /** - * Frees any resources associated with the crate::lightning::offers::offer::Quantity, if we are in the Some state + * Frees any resources associated with the crate::c_types::derived::CVec_u8Z, if we are in the Some state */ -void COption_QuantityZ_free(struct LDKCOption_QuantityZ _res); +void COption_CVec_u8ZZ_free(struct LDKCOption_CVec_u8ZZ _res); /** - * Creates a new COption_QuantityZ which has the same data as `orig` + * Creates a new COption_CVec_u8ZZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_QuantityZ COption_QuantityZ_clone(const struct LDKCOption_QuantityZ *NONNULL_PTR orig); +struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_clone(const struct LDKCOption_CVec_u8ZZ *NONNULL_PTR orig); /** - * Creates a new CResult_ThirtyTwoBytesNoneZ in the success state. + * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the success state. */ -struct LDKCResult_ThirtyTwoBytesNoneZ CResult_ThirtyTwoBytesNoneZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_ok(struct LDKRecipientOnionFields o); /** - * Creates a new CResult_ThirtyTwoBytesNoneZ in the error state. + * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the error state. */ -struct LDKCResult_ThirtyTwoBytesNoneZ CResult_ThirtyTwoBytesNoneZ_err(void); +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ThirtyTwoBytesNoneZ_is_ok(const struct LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR o); +bool CResult_RecipientOnionFieldsDecodeErrorZ_is_ok(const struct LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ThirtyTwoBytesNoneZ. + * Frees any resources used by the CResult_RecipientOnionFieldsDecodeErrorZ. */ -void CResult_ThirtyTwoBytesNoneZ_free(struct LDKCResult_ThirtyTwoBytesNoneZ _res); +void CResult_RecipientOnionFieldsDecodeErrorZ_free(struct LDKCResult_RecipientOnionFieldsDecodeErrorZ _res); /** - * Creates a new CResult_ThirtyTwoBytesNoneZ which has the same data as `orig` + * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ThirtyTwoBytesNoneZ CResult_ThirtyTwoBytesNoneZ_clone(const struct LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR orig); +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_clone(const struct LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the success state. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_ok(struct LDKBolt12Invoice o); +struct LDKC2Tuple_u64CVec_u8ZZ C2Tuple_u64CVec_u8ZZ_clone(const struct LDKC2Tuple_u64CVec_u8ZZ *NONNULL_PTR orig); /** - * Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the error state. + * Creates a new C2Tuple_u64CVec_u8ZZ from the contained elements. */ -struct LDKCResult_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKC2Tuple_u64CVec_u8ZZ C2Tuple_u64CVec_u8ZZ_new(uint64_t a, struct LDKCVec_u8Z b); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the C2Tuple_u64CVec_u8ZZ. */ -bool CResult_Bolt12InvoiceDecodeErrorZ_is_ok(const struct LDKCResult_Bolt12InvoiceDecodeErrorZ *NONNULL_PTR o); +void C2Tuple_u64CVec_u8ZZ_free(struct LDKC2Tuple_u64CVec_u8ZZ _res); /** - * Frees any resources used by the CResult_Bolt12InvoiceDecodeErrorZ. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CResult_Bolt12InvoiceDecodeErrorZ_free(struct LDKCResult_Bolt12InvoiceDecodeErrorZ _res); +void CVec_C2Tuple_u64CVec_u8ZZZ_free(struct LDKCVec_C2Tuple_u64CVec_u8ZZZ _res); /** - * Creates a new CResult_Bolt12InvoiceDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_RecipientOnionFieldsNoneZ in the success state. */ -struct LDKCResult_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_clone(const struct LDKCResult_Bolt12InvoiceDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_RecipientOnionFieldsNoneZ CResult_RecipientOnionFieldsNoneZ_ok(struct LDKRecipientOnionFields o); /** - * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. + * Creates a new CResult_RecipientOnionFieldsNoneZ in the error state. */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKDelayedPaymentOutputDescriptor o); +struct LDKCResult_RecipientOnionFieldsNoneZ CResult_RecipientOnionFieldsNoneZ_err(void); /** - * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +bool CResult_RecipientOnionFieldsNoneZ_is_ok(const struct LDKCResult_RecipientOnionFieldsNoneZ *NONNULL_PTR o); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the CResult_RecipientOnionFieldsNoneZ. */ -bool CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o); +void CResult_RecipientOnionFieldsNoneZ_free(struct LDKCResult_RecipientOnionFieldsNoneZ _res); /** - * Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. - */ + * Creates a new CResult_RecipientOnionFieldsNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RecipientOnionFieldsNoneZ CResult_RecipientOnionFieldsNoneZ_clone(const struct LDKCResult_RecipientOnionFieldsNoneZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_DNSResolverMessageResponseInstructionZ C2Tuple_DNSResolverMessageResponseInstructionZ_clone(const struct LDKC2Tuple_DNSResolverMessageResponseInstructionZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_DNSResolverMessageResponseInstructionZ from the contained elements. + */ +struct LDKC2Tuple_DNSResolverMessageResponseInstructionZ C2Tuple_DNSResolverMessageResponseInstructionZ_new(struct LDKDNSResolverMessage a, struct LDKResponseInstruction b); + +/** + * Frees any resources used by the C2Tuple_DNSResolverMessageResponseInstructionZ. + */ +void C2Tuple_DNSResolverMessageResponseInstructionZ_free(struct LDKC2Tuple_DNSResolverMessageResponseInstructionZ _res); + +/** + * Constructs a new COption_C2Tuple_DNSResolverMessageResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_DNSResolverMessageResponseInstructionZ + */ +struct LDKCOption_C2Tuple_DNSResolverMessageResponseInstructionZZ COption_C2Tuple_DNSResolverMessageResponseInstructionZZ_some(struct LDKC2Tuple_DNSResolverMessageResponseInstructionZ o); + +/** + * Constructs a new COption_C2Tuple_DNSResolverMessageResponseInstructionZZ containing nothing + */ +struct LDKCOption_C2Tuple_DNSResolverMessageResponseInstructionZZ COption_C2Tuple_DNSResolverMessageResponseInstructionZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C2Tuple_DNSResolverMessageResponseInstructionZ, if we are in the Some state + */ +void COption_C2Tuple_DNSResolverMessageResponseInstructionZZ_free(struct LDKCOption_C2Tuple_DNSResolverMessageResponseInstructionZZ _res); + +/** + * Creates a new COption_C2Tuple_DNSResolverMessageResponseInstructionZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_C2Tuple_DNSResolverMessageResponseInstructionZZ COption_C2Tuple_DNSResolverMessageResponseInstructionZZ_clone(const struct LDKCOption_C2Tuple_DNSResolverMessageResponseInstructionZZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_DNSResolverMessageMessageSendInstructionsZ C2Tuple_DNSResolverMessageMessageSendInstructionsZ_clone(const struct LDKC2Tuple_DNSResolverMessageMessageSendInstructionsZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_DNSResolverMessageMessageSendInstructionsZ from the contained elements. + */ +struct LDKC2Tuple_DNSResolverMessageMessageSendInstructionsZ C2Tuple_DNSResolverMessageMessageSendInstructionsZ_new(struct LDKDNSResolverMessage a, struct LDKMessageSendInstructions b); + +/** + * Frees any resources used by the C2Tuple_DNSResolverMessageMessageSendInstructionsZ. + */ +void C2Tuple_DNSResolverMessageMessageSendInstructionsZ_free(struct LDKC2Tuple_DNSResolverMessageMessageSendInstructionsZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_DNSResolverMessageMessageSendInstructionsZZ_free(struct LDKCVec_C2Tuple_DNSResolverMessageMessageSendInstructionsZZ _res); + +/** + * Creates a new CResult_DNSResolverMessageDecodeErrorZ in the success state. + */ +struct LDKCResult_DNSResolverMessageDecodeErrorZ CResult_DNSResolverMessageDecodeErrorZ_ok(struct LDKDNSResolverMessage o); + +/** + * Creates a new CResult_DNSResolverMessageDecodeErrorZ in the error state. + */ +struct LDKCResult_DNSResolverMessageDecodeErrorZ CResult_DNSResolverMessageDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_DNSResolverMessageDecodeErrorZ_is_ok(const struct LDKCResult_DNSResolverMessageDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_DNSResolverMessageDecodeErrorZ. + */ +void CResult_DNSResolverMessageDecodeErrorZ_free(struct LDKCResult_DNSResolverMessageDecodeErrorZ _res); + +/** + * Creates a new CResult_DNSResolverMessageDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_DNSResolverMessageDecodeErrorZ CResult_DNSResolverMessageDecodeErrorZ_clone(const struct LDKCResult_DNSResolverMessageDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_HumanReadableNameNoneZ in the success state. + */ +struct LDKCResult_HumanReadableNameNoneZ CResult_HumanReadableNameNoneZ_ok(struct LDKHumanReadableName o); + +/** + * Creates a new CResult_HumanReadableNameNoneZ in the error state. + */ +struct LDKCResult_HumanReadableNameNoneZ CResult_HumanReadableNameNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_HumanReadableNameNoneZ_is_ok(const struct LDKCResult_HumanReadableNameNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_HumanReadableNameNoneZ. + */ +void CResult_HumanReadableNameNoneZ_free(struct LDKCResult_HumanReadableNameNoneZ _res); + +/** + * Creates a new CResult_HumanReadableNameNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_HumanReadableNameNoneZ CResult_HumanReadableNameNoneZ_clone(const struct LDKCResult_HumanReadableNameNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_HumanReadableNameDecodeErrorZ in the success state. + */ +struct LDKCResult_HumanReadableNameDecodeErrorZ CResult_HumanReadableNameDecodeErrorZ_ok(struct LDKHumanReadableName o); + +/** + * Creates a new CResult_HumanReadableNameDecodeErrorZ in the error state. + */ +struct LDKCResult_HumanReadableNameDecodeErrorZ CResult_HumanReadableNameDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_HumanReadableNameDecodeErrorZ_is_ok(const struct LDKCResult_HumanReadableNameDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_HumanReadableNameDecodeErrorZ. + */ +void CResult_HumanReadableNameDecodeErrorZ_free(struct LDKCResult_HumanReadableNameDecodeErrorZ _res); + +/** + * Creates a new CResult_HumanReadableNameDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_HumanReadableNameDecodeErrorZ CResult_HumanReadableNameDecodeErrorZ_clone(const struct LDKCResult_HumanReadableNameDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_DNSSECQueryDNSResolverContextZ C2Tuple_DNSSECQueryDNSResolverContextZ_clone(const struct LDKC2Tuple_DNSSECQueryDNSResolverContextZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_DNSSECQueryDNSResolverContextZ from the contained elements. + */ +struct LDKC2Tuple_DNSSECQueryDNSResolverContextZ C2Tuple_DNSSECQueryDNSResolverContextZ_new(struct LDKDNSSECQuery a, struct LDKDNSResolverContext b); + +/** + * Frees any resources used by the C2Tuple_DNSSECQueryDNSResolverContextZ. + */ +void C2Tuple_DNSSECQueryDNSResolverContextZ_free(struct LDKC2Tuple_DNSSECQueryDNSResolverContextZ _res); + +/** + * Creates a new CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ in the success state. + */ +struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ_ok(struct LDKC2Tuple_DNSSECQueryDNSResolverContextZ o); + +/** + * Creates a new CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ in the error state. + */ +struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ_is_ok(const struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ. + */ +void CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ_free(struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ _res); + +/** + * Creates a new CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ CResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ_clone(const struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_HumanReadableNameThirtyTwoBytesZ C2Tuple_HumanReadableNameThirtyTwoBytesZ_clone(const struct LDKC2Tuple_HumanReadableNameThirtyTwoBytesZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_HumanReadableNameThirtyTwoBytesZ from the contained elements. + */ +struct LDKC2Tuple_HumanReadableNameThirtyTwoBytesZ C2Tuple_HumanReadableNameThirtyTwoBytesZ_new(struct LDKHumanReadableName a, struct LDKThirtyTwoBytes b); + +/** + * Frees any resources used by the C2Tuple_HumanReadableNameThirtyTwoBytesZ. + */ +void C2Tuple_HumanReadableNameThirtyTwoBytesZ_free(struct LDKC2Tuple_HumanReadableNameThirtyTwoBytesZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZ_free(struct LDKCVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZ _res); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ_clone(const struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ from the contained elements. + */ +struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ_new(struct LDKCVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZ a, struct LDKOffer b); + +/** + * Frees any resources used by the C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ. + */ +void C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ_free(struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ _res); + +/** + * Constructs a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ containing a crate::c_types::derived::C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ + */ +struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ_some(struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ o); + +/** + * Constructs a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ containing nothing + */ +struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZ, if we are in the Some state + */ +void COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ_free(struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ _res); + +/** + * Creates a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ_clone(const struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ_clone(const struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ from the contained elements. + */ +struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ_new(struct LDKCVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZ a, struct LDKStr b); + +/** + * Frees any resources used by the C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ. + */ +void C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ_free(struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ _res); + +/** + * Constructs a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ containing a crate::c_types::derived::C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ + */ +struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ_some(struct LDKC2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ o); + +/** + * Constructs a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ containing nothing + */ +struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZ, if we are in the Some state + */ +void COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ_free(struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ _res); + +/** + * Creates a new COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ COption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ_clone(const struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_ok(struct LDKUnsignedBolt12Invoice o); + +/** + * Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_is_ok(const struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ. + */ +void CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_free(struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_clone(const struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ CResult_Bolt12InvoiceBolt12SemanticErrorZ_ok(struct LDKBolt12Invoice o); + +/** + * Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ CResult_Bolt12InvoiceBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_Bolt12InvoiceBolt12SemanticErrorZ_is_ok(const struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_Bolt12InvoiceBolt12SemanticErrorZ. + */ +void CResult_Bolt12InvoiceBolt12SemanticErrorZ_free(struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ CResult_Bolt12InvoiceBolt12SemanticErrorZ_clone(const struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_SchnorrSignatureNoneZ in the success state. + */ +struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_ok(struct LDKSchnorrSignature o); + +/** + * Creates a new CResult_SchnorrSignatureNoneZ in the error state. + */ +struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SchnorrSignatureNoneZ_is_ok(const struct LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_SchnorrSignatureNoneZ. + */ +void CResult_SchnorrSignatureNoneZ_free(struct LDKCResult_SchnorrSignatureNoneZ _res); + +/** + * Creates a new CResult_SchnorrSignatureNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_clone(const struct LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_BlindedPaymentPathZ_free(struct LDKCVec_BlindedPaymentPathZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_AddressZ_free(struct LDKCVec_AddressZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_ThirtyTwoBytesZ_free(struct LDKCVec_ThirtyTwoBytesZ _res); + +/** + * Constructs a new COption_CVec_ThirtyTwoBytesZZ containing a crate::c_types::derived::CVec_ThirtyTwoBytesZ + */ +struct LDKCOption_CVec_ThirtyTwoBytesZZ COption_CVec_ThirtyTwoBytesZZ_some(struct LDKCVec_ThirtyTwoBytesZ o); + +/** + * Constructs a new COption_CVec_ThirtyTwoBytesZZ containing nothing + */ +struct LDKCOption_CVec_ThirtyTwoBytesZZ COption_CVec_ThirtyTwoBytesZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::CVec_ThirtyTwoBytesZ, if we are in the Some state + */ +void COption_CVec_ThirtyTwoBytesZZ_free(struct LDKCOption_CVec_ThirtyTwoBytesZZ _res); + +/** + * Creates a new COption_CVec_ThirtyTwoBytesZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_CVec_ThirtyTwoBytesZZ COption_CVec_ThirtyTwoBytesZZ_clone(const struct LDKCOption_CVec_ThirtyTwoBytesZZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_AmountZ containing a crate::lightning::offers::offer::Amount + */ +struct LDKCOption_AmountZ COption_AmountZ_some(struct LDKAmount o); + +/** + * Constructs a new COption_AmountZ containing nothing + */ +struct LDKCOption_AmountZ COption_AmountZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::offers::offer::Amount, if we are in the Some state + */ +void COption_AmountZ_free(struct LDKCOption_AmountZ _res); + +/** + * Creates a new COption_AmountZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_AmountZ COption_AmountZ_clone(const struct LDKCOption_AmountZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_QuantityZ containing a crate::lightning::offers::offer::Quantity + */ +struct LDKCOption_QuantityZ COption_QuantityZ_some(struct LDKQuantity o); + +/** + * Constructs a new COption_QuantityZ containing nothing + */ +struct LDKCOption_QuantityZ COption_QuantityZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::offers::offer::Quantity, if we are in the Some state + */ +void COption_QuantityZ_free(struct LDKCOption_QuantityZ _res); + +/** + * Creates a new COption_QuantityZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_QuantityZ COption_QuantityZ_clone(const struct LDKCOption_QuantityZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ThirtyTwoBytesNoneZ in the success state. + */ +struct LDKCResult_ThirtyTwoBytesNoneZ CResult_ThirtyTwoBytesNoneZ_ok(struct LDKThirtyTwoBytes o); + +/** + * Creates a new CResult_ThirtyTwoBytesNoneZ in the error state. + */ +struct LDKCResult_ThirtyTwoBytesNoneZ CResult_ThirtyTwoBytesNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ThirtyTwoBytesNoneZ_is_ok(const struct LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ThirtyTwoBytesNoneZ. + */ +void CResult_ThirtyTwoBytesNoneZ_free(struct LDKCResult_ThirtyTwoBytesNoneZ _res); + +/** + * Creates a new CResult_ThirtyTwoBytesNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ThirtyTwoBytesNoneZ CResult_ThirtyTwoBytesNoneZ_clone(const struct LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the success state. + */ +struct LDKCResult_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_ok(struct LDKBolt12Invoice o); + +/** + * Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the error state. + */ +struct LDKCResult_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_Bolt12InvoiceDecodeErrorZ_is_ok(const struct LDKCResult_Bolt12InvoiceDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_Bolt12InvoiceDecodeErrorZ. + */ +void CResult_Bolt12InvoiceDecodeErrorZ_free(struct LDKCResult_Bolt12InvoiceDecodeErrorZ _res); + +/** + * Creates a new CResult_Bolt12InvoiceDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_clone(const struct LDKCResult_Bolt12InvoiceDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. + */ +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKDelayedPaymentOutputDescriptor o); + +/** + * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. + */ +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. + */ void CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res); /** @@ -29835,6 +31766,11 @@ struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_clon */ void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_u16Z_free(struct LDKCVec_u16Z _res); + /** * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. */ @@ -30099,6 +32035,73 @@ void C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ_free(struct LDKC4Tupl */ void CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ_free(struct LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ _res); +/** + * Constructs a new COption_AddressZ containing a crate::c_types::Address + */ +struct LDKCOption_AddressZ COption_AddressZ_some(struct LDKAddress o); + +/** + * Constructs a new COption_AddressZ containing nothing + */ +struct LDKCOption_AddressZ COption_AddressZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::Address, if we are in the Some state + */ +void COption_AddressZ_free(struct LDKCOption_AddressZ _res); + +/** + * Constructs a new COption_StrZ containing a crate::c_types::Str + */ +struct LDKCOption_StrZ COption_StrZ_some(struct LDKStr o); + +/** + * Constructs a new COption_StrZ containing nothing + */ +struct LDKCOption_StrZ COption_StrZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::Str, if we are in the Some state + */ +void COption_StrZ_free(struct LDKCOption_StrZ _res); + +/** + * Creates a new COption_StrZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_StrZ COption_StrZ_clone(const struct LDKCOption_StrZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_LSPSRequestIdAPIErrorZ in the success state. + */ +struct LDKCResult_LSPSRequestIdAPIErrorZ CResult_LSPSRequestIdAPIErrorZ_ok(struct LDKLSPSRequestId o); + +/** + * Creates a new CResult_LSPSRequestIdAPIErrorZ in the error state. + */ +struct LDKCResult_LSPSRequestIdAPIErrorZ CResult_LSPSRequestIdAPIErrorZ_err(struct LDKAPIError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_LSPSRequestIdAPIErrorZ_is_ok(const struct LDKCResult_LSPSRequestIdAPIErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_LSPSRequestIdAPIErrorZ. + */ +void CResult_LSPSRequestIdAPIErrorZ_free(struct LDKCResult_LSPSRequestIdAPIErrorZ _res); + +/** + * Creates a new CResult_LSPSRequestIdAPIErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_LSPSRequestIdAPIErrorZ CResult_LSPSRequestIdAPIErrorZ_clone(const struct LDKCResult_LSPSRequestIdAPIErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_LSPS2OpeningFeeParamsZ_free(struct LDKCVec_LSPS2OpeningFeeParamsZ _res); + /** * Creates a new CResult_OfferIdDecodeErrorZ in the success state. */ @@ -31221,27 +33224,6 @@ void CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_free(struct LDK */ struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_clone(const struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ *NONNULL_PTR orig); -/** - * Constructs a new COption_StrZ containing a crate::c_types::Str - */ -struct LDKCOption_StrZ COption_StrZ_some(struct LDKStr o); - -/** - * Constructs a new COption_StrZ containing nothing - */ -struct LDKCOption_StrZ COption_StrZ_none(void); - -/** - * Frees any resources associated with the crate::c_types::Str, if we are in the Some state - */ -void COption_StrZ_free(struct LDKCOption_StrZ _res); - -/** - * Creates a new COption_StrZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_StrZ COption_StrZ_clone(const struct LDKCOption_StrZ *NONNULL_PTR orig); - /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -31700,6 +33682,11 @@ void CResult_COption_APIErrorZDecodeErrorZ_free(struct LDKCResult_COption_APIErr */ struct LDKCResult_COption_APIErrorZDecodeErrorZ CResult_COption_APIErrorZDecodeErrorZ_clone(const struct LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR orig); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_LSPS2RawOpeningFeeParamsZ_free(struct LDKCVec_LSPS2RawOpeningFeeParamsZ _res); + /** * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. */ @@ -32316,6 +34303,11 @@ void CResult_CVec_u8ZIOErrorZ_free(struct LDKCResult_CVec_u8ZIOErrorZ _res); */ struct LDKCResult_CVec_u8ZIOErrorZ CResult_CVec_u8ZIOErrorZ_clone(const struct LDKCResult_CVec_u8ZIOErrorZ *NONNULL_PTR orig); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_StrZ_free(struct LDKCVec_StrZ _res); + /** * Creates a new CResult_CVec_StrZIOErrorZ in the success state. */ @@ -34402,6 +36394,58 @@ struct LDKCResult_ChannelShutdownStateDecodeErrorZ CResult_ChannelShutdownStateD */ void CVec_FutureZ_free(struct LDKCVec_FutureZ _res); +/** + * Creates a new CResult_RawLSPSMessageDecodeErrorZ in the success state. + */ +struct LDKCResult_RawLSPSMessageDecodeErrorZ CResult_RawLSPSMessageDecodeErrorZ_ok(struct LDKRawLSPSMessage o); + +/** + * Creates a new CResult_RawLSPSMessageDecodeErrorZ in the error state. + */ +struct LDKCResult_RawLSPSMessageDecodeErrorZ CResult_RawLSPSMessageDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RawLSPSMessageDecodeErrorZ_is_ok(const struct LDKCResult_RawLSPSMessageDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RawLSPSMessageDecodeErrorZ. + */ +void CResult_RawLSPSMessageDecodeErrorZ_free(struct LDKCResult_RawLSPSMessageDecodeErrorZ _res); + +/** + * Creates a new CResult_RawLSPSMessageDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RawLSPSMessageDecodeErrorZ CResult_RawLSPSMessageDecodeErrorZ_clone(const struct LDKCResult_RawLSPSMessageDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_LSPSDateTimeNoneZ in the success state. + */ +struct LDKCResult_LSPSDateTimeNoneZ CResult_LSPSDateTimeNoneZ_ok(struct LDKLSPSDateTime o); + +/** + * Creates a new CResult_LSPSDateTimeNoneZ in the error state. + */ +struct LDKCResult_LSPSDateTimeNoneZ CResult_LSPSDateTimeNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_LSPSDateTimeNoneZ_is_ok(const struct LDKCResult_LSPSDateTimeNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_LSPSDateTimeNoneZ. + */ +void CResult_LSPSDateTimeNoneZ_free(struct LDKCResult_LSPSDateTimeNoneZ _res); + +/** + * Creates a new CResult_LSPSDateTimeNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_LSPSDateTimeNoneZ CResult_LSPSDateTimeNoneZ_clone(const struct LDKCResult_LSPSDateTimeNoneZ *NONNULL_PTR orig); + /** * Creates a new CResult_HeldHtlcAvailableDecodeErrorZ in the success state. */ @@ -34899,6 +36943,32 @@ struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInv */ void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); +/** + * Creates a new CResult_u64NoneZ in the success state. + */ +struct LDKCResult_u64NoneZ CResult_u64NoneZ_ok(uint64_t o); + +/** + * Creates a new CResult_u64NoneZ in the error state. + */ +struct LDKCResult_u64NoneZ CResult_u64NoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_u64NoneZ_is_ok(const struct LDKCResult_u64NoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_u64NoneZ. + */ +void CResult_u64NoneZ_free(struct LDKCResult_u64NoneZ _res); + +/** + * Creates a new CResult_u64NoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_u64NoneZ CResult_u64NoneZ_clone(const struct LDKCResult_u64NoneZ *NONNULL_PTR orig); + /** * Creates a new CResult_FundingInfoDecodeErrorZ in the success state. */ @@ -41604,21960 +43674,24116 @@ MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelManager_pay_for_offer_from_human * [`PaymentPurpose::preimage`]: events::PaymentPurpose::preimage * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash */ -MUST_USE_RES struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +MUST_USE_RES struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); + +/** + * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is + * stored external to LDK. + * + * A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a + * payment secret fetched via this method or [`create_inbound_payment`], and which is at least + * the `min_value_msat` provided here, if one is provided. + * + * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though + * note that LDK will not stop you from registering duplicate payment hashes for inbound + * payments. + * + * `min_value_msat` should be set if the invoice being generated contains a value. Any payment + * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat` + * before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the + * sender \"proof-of-payment\" unless they have paid the required amount. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. This should roughly match the expiry time set in the invoice. + * After this many seconds, we will remove the inbound payment, resulting in any attempts to + * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for + * invoices when no timeout is set. + * + * Note that we use block header time to time-out pending inbound payments (with some margin + * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will + * accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry. + * If you need exact expiry semantics, you should enforce them upon receipt of + * [`PaymentClaimable`]. + * + * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta` + * set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. + * + * Note that a malicious eavesdropper can intuit whether an inbound payment was created by + * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. + * + * # Note + * + * If you register an inbound payment with this method, then serialize the `ChannelManager`, then + * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. + * + * Errors if `min_value_msat` is greater than total bitcoin supply. + * + * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable + * on versions of LDK prior to 0.0.114. + * + * [`create_inbound_payment`]: Self::create_inbound_payment + * [`PaymentClaimable`]: events::Event::PaymentClaimable + */ +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ ChannelManager_create_inbound_payment_for_hash(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry); + +/** + * Gets an LDK-generated payment preimage from a payment hash and payment secret that were + * previously returned from [`create_inbound_payment`]. + * + * [`create_inbound_payment`]: Self::create_inbound_payment + */ +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesAPIErrorZ ChannelManager_get_payment_preimage(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); + +/** + * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids + * are used when constructing the phantom invoice's route hints. + * + * [phantom node payments]: crate::sign::PhantomKeysManager + */ +MUST_USE_RES uint64_t ChannelManager_get_phantom_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Gets route hints for use in receiving [phantom node payments]. + * + * [phantom node payments]: crate::sign::PhantomKeysManager + */ +MUST_USE_RES struct LDKPhantomRouteHints ChannelManager_get_phantom_route_hints(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Gets a fake short channel id for use in receiving intercepted payments. These fake scids are + * used when constructing the route hints for HTLCs intended to be intercepted. See + * [`ChannelManager::forward_intercepted_htlc`]. + * + * Note that this method is not guaranteed to return unique values, you may need to call it a few + * times to get a unique scid. + */ +MUST_USE_RES uint64_t ChannelManager_get_intercept_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Gets inflight HTLC information by processing pending outbound payments that are in + * our channels. May be used during pathfinding to account for in-use channel liquidity. + */ +MUST_USE_RES struct LDKInFlightHtlcs ChannelManager_compute_inflight_htlcs(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + */ +struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new EventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + */ +struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new Listen which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is + */ +struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new Confirm which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is + */ +struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Gets a [`Future`] that completes when this [`ChannelManager`] may need to be persisted or + * may have events that need processing. + * + * In order to check if this [`ChannelManager`] needs persisting, call + * [`Self::get_and_clear_needs_persistence`]. + * + * Note that callbacks registered on the [`Future`] MUST NOT call back into this + * [`ChannelManager`] and should instead register actions to be taken later. + */ +MUST_USE_RES struct LDKFuture ChannelManager_get_event_or_persistence_needed_future(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Returns true if this [`ChannelManager`] needs to be persisted. + * + * See [`Self::get_event_or_persistence_needed_future`] for retrieving a [`Future`] that + * indicates this should be checked. + */ +MUST_USE_RES bool ChannelManager_get_and_clear_needs_persistence(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Gets the latest best block which was connected either via the [`chain::Listen`] or + * [`chain::Confirm`] interfaces. + */ +MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Fetches the set of [`NodeFeatures`] flags that are provided by or required by + * [`ChannelManager`]. + */ +MUST_USE_RES struct LDKNodeFeatures ChannelManager_node_features(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Fetches the set of [`ChannelFeatures`] flags that are provided by or required by + * [`ChannelManager`]. + */ +MUST_USE_RES struct LDKChannelFeatures ChannelManager_channel_features(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Fetches the set of [`ChannelTypeFeatures`] flags that are provided by or required by + * [`ChannelManager`]. + */ +MUST_USE_RES struct LDKChannelTypeFeatures ChannelManager_channel_type_features(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Fetches the set of [`InitFeatures`] flags that are provided by or required by + * [`ChannelManager`]. + */ +MUST_USE_RES struct LDKInitFeatures ChannelManager_init_features(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is + */ +struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is + */ +struct LDKOffersMessageHandler ChannelManager_as_OffersMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is + */ +struct LDKAsyncPaymentsMessageHandler ChannelManager_as_AsyncPaymentsMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new DNSResolverMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned DNSResolverMessageHandler must be freed before this_arg is + */ +struct LDKDNSResolverMessageHandler ChannelManager_as_DNSResolverMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is + */ +struct LDKNodeIdLookUp ChannelManager_as_NodeIdLookUp(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Fetches the set of [`InitFeatures`] flags that are provided by or required by + * [`ChannelManager`]. + */ +struct LDKInitFeatures provided_init_features(const struct LDKUserConfig *NONNULL_PTR config); + +/** + * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read + */ +struct LDKCVec_u8Z PhantomRouteHints_write(const struct LDKPhantomRouteHints *NONNULL_PTR obj); + +/** + * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write + */ +struct LDKCResult_PhantomRouteHintsDecodeErrorZ PhantomRouteHints_read(struct LDKu8slice ser); + +/** + * Serialize the BlindedForward object into a byte array which can be read by BlindedForward_read + */ +struct LDKCVec_u8Z BlindedForward_write(const struct LDKBlindedForward *NONNULL_PTR obj); + +/** + * Read a BlindedForward from a byte array, created by BlindedForward_write + */ +struct LDKCResult_BlindedForwardDecodeErrorZ BlindedForward_read(struct LDKu8slice ser); + +/** + * Serialize the PendingHTLCRouting object into a byte array which can be read by PendingHTLCRouting_read + */ +struct LDKCVec_u8Z PendingHTLCRouting_write(const struct LDKPendingHTLCRouting *NONNULL_PTR obj); + +/** + * Read a PendingHTLCRouting from a byte array, created by PendingHTLCRouting_write + */ +struct LDKCResult_PendingHTLCRoutingDecodeErrorZ PendingHTLCRouting_read(struct LDKu8slice ser); + +/** + * Serialize the PendingHTLCInfo object into a byte array which can be read by PendingHTLCInfo_read + */ +struct LDKCVec_u8Z PendingHTLCInfo_write(const struct LDKPendingHTLCInfo *NONNULL_PTR obj); + +/** + * Read a PendingHTLCInfo from a byte array, created by PendingHTLCInfo_write + */ +struct LDKCResult_PendingHTLCInfoDecodeErrorZ PendingHTLCInfo_read(struct LDKu8slice ser); + +/** + * Serialize the BlindedFailure object into a byte array which can be read by BlindedFailure_read + */ +struct LDKCVec_u8Z BlindedFailure_write(const enum LDKBlindedFailure *NONNULL_PTR obj); + +/** + * Read a BlindedFailure from a byte array, created by BlindedFailure_write + */ +struct LDKCResult_BlindedFailureDecodeErrorZ BlindedFailure_read(struct LDKu8slice ser); + +/** + * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read + */ +struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); + +/** + * Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. + */ +void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_obj); + +/** + * A cryptographically secure source of entropy. + */ +const struct LDKEntropySource *ChannelManagerReadArgs_get_entropy_source(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * A cryptographically secure source of entropy. + */ +void ChannelManagerReadArgs_set_entropy_source(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKEntropySource val); + +/** + * A signer that is able to perform node-scoped cryptographic operations. + */ +const struct LDKNodeSigner *ChannelManagerReadArgs_get_node_signer(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * A signer that is able to perform node-scoped cryptographic operations. + */ +void ChannelManagerReadArgs_set_node_signer(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKNodeSigner val); + +/** + * The keys provider which will give us relevant keys. Some keys will be loaded during + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. + */ +const struct LDKSignerProvider *ChannelManagerReadArgs_get_signer_provider(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * The keys provider which will give us relevant keys. Some keys will be loaded during + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. + */ +void ChannelManagerReadArgs_set_signer_provider(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKSignerProvider val); + +/** + * The fee_estimator for use in the ChannelManager in the future. + * + * No calls to the FeeEstimator will be made during deserialization. + */ +const struct LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * The fee_estimator for use in the ChannelManager in the future. + * + * No calls to the FeeEstimator will be made during deserialization. + */ +void ChannelManagerReadArgs_set_fee_estimator(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKFeeEstimator val); + +/** + * The chain::Watch for use in the ChannelManager in the future. + * + * No calls to the chain::Watch will be made during deserialization. It is assumed that + * you have deserialized ChannelMonitors separately and will add them to your + * chain::Watch after deserializing this ChannelManager. + */ +const struct LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * The chain::Watch for use in the ChannelManager in the future. + * + * No calls to the chain::Watch will be made during deserialization. It is assumed that + * you have deserialized ChannelMonitors separately and will add them to your + * chain::Watch after deserializing this ChannelManager. + */ +void ChannelManagerReadArgs_set_chain_monitor(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKWatch val); + +/** + * The BroadcasterInterface which will be used in the ChannelManager in the future and may be + * used to broadcast the latest local commitment transactions of channels which must be + * force-closed during deserialization. + */ +const struct LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * The BroadcasterInterface which will be used in the ChannelManager in the future and may be + * used to broadcast the latest local commitment transactions of channels which must be + * force-closed during deserialization. + */ +void ChannelManagerReadArgs_set_tx_broadcaster(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKBroadcasterInterface val); + +/** + * The router which will be used in the ChannelManager in the future for finding routes + * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. + * + * No calls to the router will be made during deserialization. + */ +const struct LDKRouter *ChannelManagerReadArgs_get_router(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * The router which will be used in the ChannelManager in the future for finding routes + * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. + * + * No calls to the router will be made during deserialization. + */ +void ChannelManagerReadArgs_set_router(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKRouter val); + +/** + * The [`MessageRouter`] used for constructing [`BlindedMessagePath`]s for [`Offer`]s, + * [`Refund`]s, and any reply paths. + */ +const struct LDKMessageRouter *ChannelManagerReadArgs_get_message_router(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * The [`MessageRouter`] used for constructing [`BlindedMessagePath`]s for [`Offer`]s, + * [`Refund`]s, and any reply paths. + */ +void ChannelManagerReadArgs_set_message_router(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKMessageRouter val); + +/** + * The Logger for use in the ChannelManager and which may be used to log information during + * deserialization. + */ +const struct LDKLogger *ChannelManagerReadArgs_get_logger(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * The Logger for use in the ChannelManager and which may be used to log information during + * deserialization. + */ +void ChannelManagerReadArgs_set_logger(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKLogger val); + +/** + * Default settings used for new channels. Any existing channels will continue to use the + * runtime settings which were stored when the ChannelManager was serialized. + */ +struct LDKUserConfig ChannelManagerReadArgs_get_default_config(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * Default settings used for new channels. Any existing channels will continue to use the + * runtime settings which were stored when the ChannelManager was serialized. + */ +void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKUserConfig val); + +/** + * Simple utility function to create a ChannelManagerReadArgs which creates the monitor + * HashMap for you. This is primarily useful for C bindings where it is not practical to + * populate a HashMap directly from C. + */ +MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKSignerProvider signer_provider, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKRouter router, struct LDKMessageRouter message_router, struct LDKLogger logger, struct LDKUserConfig default_config, struct LDKCVec_ChannelMonitorZ channel_monitors); + +/** + * Read a C2Tuple_ThirtyTwoBytesChannelManagerZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelManagerZ_write + */ +struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ C2Tuple_ThirtyTwoBytesChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg); + +/** + * Frees any resources used by the DelayedPaymentBasepoint, if is_owned is set and inner is non-NULL. + */ +void DelayedPaymentBasepoint_free(struct LDKDelayedPaymentBasepoint this_obj); + +struct LDKPublicKey DelayedPaymentBasepoint_get_a(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_ptr); + +void DelayedPaymentBasepoint_set_a(struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new DelayedPaymentBasepoint given each field + */ +MUST_USE_RES struct LDKDelayedPaymentBasepoint DelayedPaymentBasepoint_new(struct LDKPublicKey a_arg); + +/** + * Checks if two DelayedPaymentBasepoints contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool DelayedPaymentBasepoint_eq(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR a, const struct LDKDelayedPaymentBasepoint *NONNULL_PTR b); + +/** + * Creates a copy of the DelayedPaymentBasepoint + */ +struct LDKDelayedPaymentBasepoint DelayedPaymentBasepoint_clone(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the DelayedPaymentBasepoint. + */ +uint64_t DelayedPaymentBasepoint_hash(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR o); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey DelayedPaymentBasepoint_to_public_key(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_arg); + +/** + *Derives the \"tweak\" used in calculate [`DelayedPaymentKey::from_basepoint`].\n\n[`DelayedPaymentKey::from_basepoint`] calculates a private key as:\n`privkey = basepoint_secret + SHA256(per_commitment_point || basepoint)`\n\nThis calculates the hash part in the tweak derivation process, which is used to\nensure that each key is unique and cannot be guessed by an external party. + */ +MUST_USE_RES struct LDKThirtyTwoBytes DelayedPaymentBasepoint_derive_add_tweak(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_arg, struct LDKPublicKey per_commitment_point); + +/** + * Serialize the DelayedPaymentBasepoint object into a byte array which can be read by DelayedPaymentBasepoint_read + */ +struct LDKCVec_u8Z DelayedPaymentBasepoint_write(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR obj); + +/** + * Read a DelayedPaymentBasepoint from a byte array, created by DelayedPaymentBasepoint_write + */ +struct LDKCResult_DelayedPaymentBasepointDecodeErrorZ DelayedPaymentBasepoint_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the DelayedPaymentKey, if is_owned is set and inner is non-NULL. + */ +void DelayedPaymentKey_free(struct LDKDelayedPaymentKey this_obj); + +struct LDKPublicKey DelayedPaymentKey_get_a(const struct LDKDelayedPaymentKey *NONNULL_PTR this_ptr); + +void DelayedPaymentKey_set_a(struct LDKDelayedPaymentKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new DelayedPaymentKey given each field + */ +MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_new(struct LDKPublicKey a_arg); + +/** + * Checks if two DelayedPaymentKeys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool DelayedPaymentKey_eq(const struct LDKDelayedPaymentKey *NONNULL_PTR a, const struct LDKDelayedPaymentKey *NONNULL_PTR b); + +/** + * Creates a copy of the DelayedPaymentKey + */ +struct LDKDelayedPaymentKey DelayedPaymentKey_clone(const struct LDKDelayedPaymentKey *NONNULL_PTR orig); + +/** + *Derive a public delayedpubkey using one node\'s `per_commitment_point` and its countersignatory\'s `basepoint` + */ +MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_from_basepoint(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); + +/** + *Build a delayedpubkey directly from an already-derived private key + */ +MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_from_secret_key(const uint8_t (*sk)[32]); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey DelayedPaymentKey_to_public_key(const struct LDKDelayedPaymentKey *NONNULL_PTR this_arg); + +/** + * Serialize the DelayedPaymentKey object into a byte array which can be read by DelayedPaymentKey_read + */ +struct LDKCVec_u8Z DelayedPaymentKey_write(const struct LDKDelayedPaymentKey *NONNULL_PTR obj); + +/** + * Read a DelayedPaymentKey from a byte array, created by DelayedPaymentKey_write + */ +struct LDKCResult_DelayedPaymentKeyDecodeErrorZ DelayedPaymentKey_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the HtlcBasepoint, if is_owned is set and inner is non-NULL. + */ +void HtlcBasepoint_free(struct LDKHtlcBasepoint this_obj); + +struct LDKPublicKey HtlcBasepoint_get_a(const struct LDKHtlcBasepoint *NONNULL_PTR this_ptr); + +void HtlcBasepoint_set_a(struct LDKHtlcBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new HtlcBasepoint given each field + */ +MUST_USE_RES struct LDKHtlcBasepoint HtlcBasepoint_new(struct LDKPublicKey a_arg); + +/** + * Checks if two HtlcBasepoints contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool HtlcBasepoint_eq(const struct LDKHtlcBasepoint *NONNULL_PTR a, const struct LDKHtlcBasepoint *NONNULL_PTR b); + +/** + * Creates a copy of the HtlcBasepoint + */ +struct LDKHtlcBasepoint HtlcBasepoint_clone(const struct LDKHtlcBasepoint *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the HtlcBasepoint. + */ +uint64_t HtlcBasepoint_hash(const struct LDKHtlcBasepoint *NONNULL_PTR o); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey HtlcBasepoint_to_public_key(const struct LDKHtlcBasepoint *NONNULL_PTR this_arg); + +/** + *Derives the \"tweak\" used in calculate [`HtlcKey::from_basepoint`].\n\n[`HtlcKey::from_basepoint`] calculates a private key as:\n`privkey = basepoint_secret + SHA256(per_commitment_point || basepoint)`\n\nThis calculates the hash part in the tweak derivation process, which is used to\nensure that each key is unique and cannot be guessed by an external party. + */ +MUST_USE_RES struct LDKThirtyTwoBytes HtlcBasepoint_derive_add_tweak(const struct LDKHtlcBasepoint *NONNULL_PTR this_arg, struct LDKPublicKey per_commitment_point); + +/** + * Serialize the HtlcBasepoint object into a byte array which can be read by HtlcBasepoint_read + */ +struct LDKCVec_u8Z HtlcBasepoint_write(const struct LDKHtlcBasepoint *NONNULL_PTR obj); + +/** + * Read a HtlcBasepoint from a byte array, created by HtlcBasepoint_write + */ +struct LDKCResult_HtlcBasepointDecodeErrorZ HtlcBasepoint_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the HtlcKey, if is_owned is set and inner is non-NULL. + */ +void HtlcKey_free(struct LDKHtlcKey this_obj); + +struct LDKPublicKey HtlcKey_get_a(const struct LDKHtlcKey *NONNULL_PTR this_ptr); + +void HtlcKey_set_a(struct LDKHtlcKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new HtlcKey given each field + */ +MUST_USE_RES struct LDKHtlcKey HtlcKey_new(struct LDKPublicKey a_arg); + +/** + * Checks if two HtlcKeys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool HtlcKey_eq(const struct LDKHtlcKey *NONNULL_PTR a, const struct LDKHtlcKey *NONNULL_PTR b); + +/** + * Creates a copy of the HtlcKey + */ +struct LDKHtlcKey HtlcKey_clone(const struct LDKHtlcKey *NONNULL_PTR orig); + +/** + *Derive a public htlcpubkey using one node\'s `per_commitment_point` and its countersignatory\'s `basepoint` + */ +MUST_USE_RES struct LDKHtlcKey HtlcKey_from_basepoint(const struct LDKHtlcBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); + +/** + *Build a htlcpubkey directly from an already-derived private key + */ +MUST_USE_RES struct LDKHtlcKey HtlcKey_from_secret_key(const uint8_t (*sk)[32]); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey HtlcKey_to_public_key(const struct LDKHtlcKey *NONNULL_PTR this_arg); + +/** + * Serialize the HtlcKey object into a byte array which can be read by HtlcKey_read + */ +struct LDKCVec_u8Z HtlcKey_write(const struct LDKHtlcKey *NONNULL_PTR obj); + +/** + * Read a HtlcKey from a byte array, created by HtlcKey_write + */ +struct LDKCResult_HtlcKeyDecodeErrorZ HtlcKey_read(struct LDKu8slice ser); + +/** + * Adds a tweak to a public key to derive a new public key. + * + * May panic if `tweak` is not the output of a SHA-256 hash. + */ +struct LDKPublicKey add_public_key_tweak(struct LDKPublicKey base_point, const uint8_t (*tweak)[32]); + +/** + * Frees any resources used by the RevocationBasepoint, if is_owned is set and inner is non-NULL. + */ +void RevocationBasepoint_free(struct LDKRevocationBasepoint this_obj); + +struct LDKPublicKey RevocationBasepoint_get_a(const struct LDKRevocationBasepoint *NONNULL_PTR this_ptr); + +void RevocationBasepoint_set_a(struct LDKRevocationBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new RevocationBasepoint given each field + */ +MUST_USE_RES struct LDKRevocationBasepoint RevocationBasepoint_new(struct LDKPublicKey a_arg); + +/** + * Checks if two RevocationBasepoints contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool RevocationBasepoint_eq(const struct LDKRevocationBasepoint *NONNULL_PTR a, const struct LDKRevocationBasepoint *NONNULL_PTR b); + +/** + * Creates a copy of the RevocationBasepoint + */ +struct LDKRevocationBasepoint RevocationBasepoint_clone(const struct LDKRevocationBasepoint *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the RevocationBasepoint. + */ +uint64_t RevocationBasepoint_hash(const struct LDKRevocationBasepoint *NONNULL_PTR o); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey RevocationBasepoint_to_public_key(const struct LDKRevocationBasepoint *NONNULL_PTR this_arg); + +/** + * Serialize the RevocationBasepoint object into a byte array which can be read by RevocationBasepoint_read + */ +struct LDKCVec_u8Z RevocationBasepoint_write(const struct LDKRevocationBasepoint *NONNULL_PTR obj); + +/** + * Read a RevocationBasepoint from a byte array, created by RevocationBasepoint_write + */ +struct LDKCResult_RevocationBasepointDecodeErrorZ RevocationBasepoint_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the RevocationKey, if is_owned is set and inner is non-NULL. + */ +void RevocationKey_free(struct LDKRevocationKey this_obj); + +struct LDKPublicKey RevocationKey_get_a(const struct LDKRevocationKey *NONNULL_PTR this_ptr); + +void RevocationKey_set_a(struct LDKRevocationKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new RevocationKey given each field + */ +MUST_USE_RES struct LDKRevocationKey RevocationKey_new(struct LDKPublicKey a_arg); + +/** + * Checks if two RevocationKeys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool RevocationKey_eq(const struct LDKRevocationKey *NONNULL_PTR a, const struct LDKRevocationKey *NONNULL_PTR b); + +/** + * Creates a copy of the RevocationKey + */ +struct LDKRevocationKey RevocationKey_clone(const struct LDKRevocationKey *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the RevocationKey. + */ +uint64_t RevocationKey_hash(const struct LDKRevocationKey *NONNULL_PTR o); + +/** + * Derives a per-commitment-transaction revocation public key from one party's per-commitment + * point and the other party's [`RevocationBasepoint`]. This is the public equivalent of + * [`chan_utils::derive_private_revocation_key`] - using only public keys to derive a public + * key instead of private keys. + * + * Note that this is infallible iff we trust that at least one of the two input keys are randomly + * generated (ie our own). + * + * [`chan_utils::derive_private_revocation_key`]: crate::ln::chan_utils::derive_private_revocation_key + */ +MUST_USE_RES struct LDKRevocationKey RevocationKey_from_basepoint(const struct LDKRevocationBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey RevocationKey_to_public_key(const struct LDKRevocationKey *NONNULL_PTR this_arg); + +/** + * Serialize the RevocationKey object into a byte array which can be read by RevocationKey_read + */ +struct LDKCVec_u8Z RevocationKey_write(const struct LDKRevocationKey *NONNULL_PTR obj); + +/** + * Read a RevocationKey from a byte array, created by RevocationKey_write + */ +struct LDKCResult_RevocationKeyDecodeErrorZ RevocationKey_read(struct LDKu8slice ser); + +/** + * Creates a copy of the InboundHTLCStateDetails + */ +enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_clone(const enum LDKInboundHTLCStateDetails *NONNULL_PTR orig); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToAdd-variant InboundHTLCStateDetails + */ +enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_awaiting_remote_revoke_to_add(void); + +/** + * Utility method to constructs a new Committed-variant InboundHTLCStateDetails + */ +enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_committed(void); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToRemoveFulfill-variant InboundHTLCStateDetails + */ +enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_awaiting_remote_revoke_to_remove_fulfill(void); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToRemoveFail-variant InboundHTLCStateDetails + */ +enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_awaiting_remote_revoke_to_remove_fail(void); + +/** + * Serialize the InboundHTLCStateDetails object into a byte array which can be read by InboundHTLCStateDetails_read + */ +struct LDKCVec_u8Z InboundHTLCStateDetails_write(const enum LDKInboundHTLCStateDetails *NONNULL_PTR obj); + +/** + * Read a InboundHTLCStateDetails from a byte array, created by InboundHTLCStateDetails_write + */ +struct LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ InboundHTLCStateDetails_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the InboundHTLCDetails, if is_owned is set and inner is non-NULL. + */ +void InboundHTLCDetails_free(struct LDKInboundHTLCDetails this_obj); + +/** + * The HTLC ID. + * The IDs are incremented by 1 starting from 0 for each offered HTLC. + * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced + * and not part of any commitment transaction. + */ +uint64_t InboundHTLCDetails_get_htlc_id(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The HTLC ID. + * The IDs are incremented by 1 starting from 0 for each offered HTLC. + * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced + * and not part of any commitment transaction. + */ +void InboundHTLCDetails_set_htlc_id(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The amount in msat. + */ +uint64_t InboundHTLCDetails_get_amount_msat(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The amount in msat. + */ +void InboundHTLCDetails_set_amount_msat(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The block height at which this HTLC expires. + */ +uint32_t InboundHTLCDetails_get_cltv_expiry(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The block height at which this HTLC expires. + */ +void InboundHTLCDetails_set_cltv_expiry(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The payment hash. + */ +const uint8_t (*InboundHTLCDetails_get_payment_hash(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr))[32]; + +/** + * The payment hash. + */ +void InboundHTLCDetails_set_payment_hash(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * The state of the HTLC in the state machine. + * + * Determines on which commitment transactions the HTLC is included and what message the HTLC is + * waiting for to advance to the next state. + * + * See [`InboundHTLCStateDetails`] for information on the specific states. + * + * LDK will always fill this field in, but when downgrading to prior versions of LDK, new + * states may result in `None` here. + */ +struct LDKCOption_InboundHTLCStateDetailsZ InboundHTLCDetails_get_state(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The state of the HTLC in the state machine. + * + * Determines on which commitment transactions the HTLC is included and what message the HTLC is + * waiting for to advance to the next state. + * + * See [`InboundHTLCStateDetails`] for information on the specific states. + * + * LDK will always fill this field in, but when downgrading to prior versions of LDK, new + * states may result in `None` here. + */ +void InboundHTLCDetails_set_state(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_InboundHTLCStateDetailsZ val); + +/** + * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed + * from the local commitment transaction and added to the commitment transaction fee. + * For non-anchor channels, this takes into account the cost of the second-stage HTLC + * transactions as well. + * + * When the local commitment transaction is broadcasted as part of a unilateral closure, + * the value of this HTLC will therefore not be claimable but instead burned as a transaction + * fee. + * + * Note that dust limits are specific to each party. An HTLC can be dust for the local + * commitment transaction but not for the counterparty's commitment transaction and vice versa. + */ +bool InboundHTLCDetails_get_is_dust(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed + * from the local commitment transaction and added to the commitment transaction fee. + * For non-anchor channels, this takes into account the cost of the second-stage HTLC + * transactions as well. + * + * When the local commitment transaction is broadcasted as part of a unilateral closure, + * the value of this HTLC will therefore not be claimable but instead burned as a transaction + * fee. + * + * Note that dust limits are specific to each party. An HTLC can be dust for the local + * commitment transaction but not for the counterparty's commitment transaction and vice versa. + */ +void InboundHTLCDetails_set_is_dust(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, bool val); + +/** + * Constructs a new InboundHTLCDetails given each field + */ +MUST_USE_RES struct LDKInboundHTLCDetails InboundHTLCDetails_new(uint64_t htlc_id_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_InboundHTLCStateDetailsZ state_arg, bool is_dust_arg); + +/** + * Creates a copy of the InboundHTLCDetails + */ +struct LDKInboundHTLCDetails InboundHTLCDetails_clone(const struct LDKInboundHTLCDetails *NONNULL_PTR orig); + +/** + * Serialize the InboundHTLCDetails object into a byte array which can be read by InboundHTLCDetails_read + */ +struct LDKCVec_u8Z InboundHTLCDetails_write(const struct LDKInboundHTLCDetails *NONNULL_PTR obj); + +/** + * Read a InboundHTLCDetails from a byte array, created by InboundHTLCDetails_write + */ +struct LDKCResult_InboundHTLCDetailsDecodeErrorZ InboundHTLCDetails_read(struct LDKu8slice ser); + +/** + * Creates a copy of the OutboundHTLCStateDetails + */ +enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_clone(const enum LDKOutboundHTLCStateDetails *NONNULL_PTR orig); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToAdd-variant OutboundHTLCStateDetails + */ +enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_awaiting_remote_revoke_to_add(void); + +/** + * Utility method to constructs a new Committed-variant OutboundHTLCStateDetails + */ +enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_committed(void); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToRemoveSuccess-variant OutboundHTLCStateDetails + */ +enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_awaiting_remote_revoke_to_remove_success(void); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToRemoveFailure-variant OutboundHTLCStateDetails + */ +enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_awaiting_remote_revoke_to_remove_failure(void); + +/** + * Serialize the OutboundHTLCStateDetails object into a byte array which can be read by OutboundHTLCStateDetails_read + */ +struct LDKCVec_u8Z OutboundHTLCStateDetails_write(const enum LDKOutboundHTLCStateDetails *NONNULL_PTR obj); + +/** + * Read a OutboundHTLCStateDetails from a byte array, created by OutboundHTLCStateDetails_write + */ +struct LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ OutboundHTLCStateDetails_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the OutboundHTLCDetails, if is_owned is set and inner is non-NULL. + */ +void OutboundHTLCDetails_free(struct LDKOutboundHTLCDetails this_obj); + +/** + * The HTLC ID. + * The IDs are incremented by 1 starting from 0 for each offered HTLC. + * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced + * and not part of any commitment transaction. + * + * Not present when we are awaiting a remote revocation and the HTLC is not added yet. + */ +struct LDKCOption_u64Z OutboundHTLCDetails_get_htlc_id(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The HTLC ID. + * The IDs are incremented by 1 starting from 0 for each offered HTLC. + * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced + * and not part of any commitment transaction. + * + * Not present when we are awaiting a remote revocation and the HTLC is not added yet. + */ +void OutboundHTLCDetails_set_htlc_id(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The amount in msat. + */ +uint64_t OutboundHTLCDetails_get_amount_msat(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The amount in msat. + */ +void OutboundHTLCDetails_set_amount_msat(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The block height at which this HTLC expires. + */ +uint32_t OutboundHTLCDetails_get_cltv_expiry(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The block height at which this HTLC expires. + */ +void OutboundHTLCDetails_set_cltv_expiry(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The payment hash. + */ +const uint8_t (*OutboundHTLCDetails_get_payment_hash(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr))[32]; + +/** + * The payment hash. + */ +void OutboundHTLCDetails_set_payment_hash(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * The state of the HTLC in the state machine. + * + * Determines on which commitment transactions the HTLC is included and what message the HTLC is + * waiting for to advance to the next state. + * + * See [`OutboundHTLCStateDetails`] for information on the specific states. + * + * LDK will always fill this field in, but when downgrading to prior versions of LDK, new + * states may result in `None` here. + */ +struct LDKCOption_OutboundHTLCStateDetailsZ OutboundHTLCDetails_get_state(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The state of the HTLC in the state machine. + * + * Determines on which commitment transactions the HTLC is included and what message the HTLC is + * waiting for to advance to the next state. + * + * See [`OutboundHTLCStateDetails`] for information on the specific states. + * + * LDK will always fill this field in, but when downgrading to prior versions of LDK, new + * states may result in `None` here. + */ +void OutboundHTLCDetails_set_state(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_OutboundHTLCStateDetailsZ val); + +/** + * The extra fee being skimmed off the top of this HTLC. + */ +struct LDKCOption_u64Z OutboundHTLCDetails_get_skimmed_fee_msat(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The extra fee being skimmed off the top of this HTLC. + */ +void OutboundHTLCDetails_set_skimmed_fee_msat(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed + * from the local commitment transaction and added to the commitment transaction fee. + * For non-anchor channels, this takes into account the cost of the second-stage HTLC + * transactions as well. + * + * When the local commitment transaction is broadcasted as part of a unilateral closure, + * the value of this HTLC will therefore not be claimable but instead burned as a transaction + * fee. + * + * Note that dust limits are specific to each party. An HTLC can be dust for the local + * commitment transaction but not for the counterparty's commitment transaction and vice versa. + */ +bool OutboundHTLCDetails_get_is_dust(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed + * from the local commitment transaction and added to the commitment transaction fee. + * For non-anchor channels, this takes into account the cost of the second-stage HTLC + * transactions as well. + * + * When the local commitment transaction is broadcasted as part of a unilateral closure, + * the value of this HTLC will therefore not be claimable but instead burned as a transaction + * fee. + * + * Note that dust limits are specific to each party. An HTLC can be dust for the local + * commitment transaction but not for the counterparty's commitment transaction and vice versa. + */ +void OutboundHTLCDetails_set_is_dust(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, bool val); + +/** + * Constructs a new OutboundHTLCDetails given each field + */ +MUST_USE_RES struct LDKOutboundHTLCDetails OutboundHTLCDetails_new(struct LDKCOption_u64Z htlc_id_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_OutboundHTLCStateDetailsZ state_arg, struct LDKCOption_u64Z skimmed_fee_msat_arg, bool is_dust_arg); + +/** + * Creates a copy of the OutboundHTLCDetails + */ +struct LDKOutboundHTLCDetails OutboundHTLCDetails_clone(const struct LDKOutboundHTLCDetails *NONNULL_PTR orig); + +/** + * Serialize the OutboundHTLCDetails object into a byte array which can be read by OutboundHTLCDetails_read + */ +struct LDKCVec_u8Z OutboundHTLCDetails_write(const struct LDKOutboundHTLCDetails *NONNULL_PTR obj); + +/** + * Read a OutboundHTLCDetails from a byte array, created by OutboundHTLCDetails_write + */ +struct LDKCResult_OutboundHTLCDetailsDecodeErrorZ OutboundHTLCDetails_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL. + */ +void CounterpartyForwardingInfo_free(struct LDKCounterpartyForwardingInfo this_obj); + +/** + * Base routing fee in millisatoshis. + */ +uint32_t CounterpartyForwardingInfo_get_fee_base_msat(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + +/** + * Base routing fee in millisatoshis. + */ +void CounterpartyForwardingInfo_set_fee_base_msat(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); + +/** + * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + */ +uint32_t CounterpartyForwardingInfo_get_fee_proportional_millionths(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + +/** + * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + */ +void CounterpartyForwardingInfo_set_fee_proportional_millionths(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, + * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s + * `cltv_expiry_delta` for more details. + */ +uint16_t CounterpartyForwardingInfo_get_cltv_expiry_delta(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + +/** + * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, + * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s + * `cltv_expiry_delta` for more details. + */ +void CounterpartyForwardingInfo_set_cltv_expiry_delta(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint16_t val); + +/** + * Constructs a new CounterpartyForwardingInfo given each field + */ +MUST_USE_RES struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg); + +/** + * Creates a copy of the CounterpartyForwardingInfo + */ +struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_clone(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR orig); + +/** + * Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read + */ +struct LDKCVec_u8Z CounterpartyForwardingInfo_write(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR obj); + +/** + * Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CounterpartyForwardingInfo_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL. + */ +void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); + +/** + * The node_id of our counterparty + */ +struct LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * The node_id of our counterparty + */ +void ChannelCounterparty_set_node_id(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. + */ +struct LDKInitFeatures ChannelCounterparty_get_features(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. + */ +void ChannelCounterparty_set_features(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKInitFeatures val); + +/** + * The value, in satoshis, that must always be held in the channel for our counterparty. This + * value ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * This value is not included in [`inbound_capacity_msat`] as it can never be spent. + * + * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + */ +uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * The value, in satoshis, that must always be held in the channel for our counterparty. This + * value ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * This value is not included in [`inbound_capacity_msat`] as it can never be spent. + * + * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + */ +void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKCounterpartyForwardingInfo ChannelCounterparty_get_forwarding_info(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChannelCounterparty_set_forwarding_info(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCounterpartyForwardingInfo val); + +/** + * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field + * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message + * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. + */ +struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_minimum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field + * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message + * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. + */ +void ChannelCounterparty_set_outbound_htlc_minimum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + */ +struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_maximum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + */ +void ChannelCounterparty_set_outbound_htlc_maximum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * Constructs a new ChannelCounterparty given each field + * + * Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKChannelCounterparty ChannelCounterparty_new(struct LDKPublicKey node_id_arg, struct LDKInitFeatures features_arg, uint64_t unspendable_punishment_reserve_arg, struct LDKCounterpartyForwardingInfo forwarding_info_arg, struct LDKCOption_u64Z outbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z outbound_htlc_maximum_msat_arg); + +/** + * Creates a copy of the ChannelCounterparty + */ +struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); + +/** + * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read + */ +struct LDKCVec_u8Z ChannelCounterparty_write(const struct LDKChannelCounterparty *NONNULL_PTR obj); + +/** + * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ ChannelCounterparty_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. + */ +void ChannelDetails_free(struct LDKChannelDetails this_obj); + +/** + * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, + * thereafter this is the txid of the funding transaction xor the funding transaction output). + * Note that this means this value is *not* persistent - it can change once during the + * lifetime of the channel. + */ +struct LDKChannelId ChannelDetails_get_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, + * thereafter this is the txid of the funding transaction xor the funding transaction output). + * Note that this means this value is *not* persistent - it can change once during the + * lifetime of the channel. + */ +void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * Parameters which apply to our counterparty. See individual fields for more information. + */ +struct LDKChannelCounterparty ChannelDetails_get_counterparty(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * Parameters which apply to our counterparty. See individual fields for more information. + */ +void ChannelDetails_set_counterparty(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelCounterparty val); + +/** + * The Channel's funding transaction output, if we've negotiated the funding transaction with + * our counterparty already. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The Channel's funding transaction output, if we've negotiated the funding transaction with + * our counterparty already. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val); + +/** + * The features which this channel operates with. See individual features for more info. + * + * `None` until negotiation completes and the channel type is finalized. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelTypeFeatures ChannelDetails_get_channel_type(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The features which this channel operates with. See individual features for more info. + * + * `None` until negotiation completes and the channel type is finalized. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChannelDetails_set_channel_type(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); + +/** + * The position of the funding transaction in the chain. None if the funding transaction has + * not yet been confirmed and the channel fully opened. + * + * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound + * payments instead of this. See [`get_inbound_payment_scid`]. + * + * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may + * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. + * + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`outbound_scid_alias`]: Self::outbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid + * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid + * [`confirmations_required`]: Self::confirmations_required + */ +struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The position of the funding transaction in the chain. None if the funding transaction has + * not yet been confirmed and the channel fully opened. + * + * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound + * payments instead of this. See [`get_inbound_payment_scid`]. + * + * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may + * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. + * + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`outbound_scid_alias`]: Self::outbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid + * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid + * [`confirmations_required`]: Self::confirmations_required + */ +void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * An optional [`short_channel_id`] alias for this channel, randomly generated by us and + * usable in place of [`short_channel_id`] to reference the channel in outbound routes when + * the channel has not yet been confirmed (as long as [`confirmations_required`] is + * `Some(0)`). + * + * This will be `None` as long as the channel is not available for routing outbound payments. + * + * [`short_channel_id`]: Self::short_channel_id + * [`confirmations_required`]: Self::confirmations_required + */ +struct LDKCOption_u64Z ChannelDetails_get_outbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * An optional [`short_channel_id`] alias for this channel, randomly generated by us and + * usable in place of [`short_channel_id`] to reference the channel in outbound routes when + * the channel has not yet been confirmed (as long as [`confirmations_required`] is + * `Some(0)`). + * + * This will be `None` as long as the channel is not available for routing outbound payments. + * + * [`short_channel_id`]: Self::short_channel_id + * [`confirmations_required`]: Self::confirmations_required + */ +void ChannelDetails_set_outbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * An optional [`short_channel_id`] alias for this channel, randomly generated by our + * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our + * counterparty will recognize the alias provided here in place of the [`short_channel_id`] + * when they see a payment to be routed to us. + * + * Our counterparty may choose to rotate this value at any time, though will always recognize + * previous values for inbound payment forwarding. + * + * [`short_channel_id`]: Self::short_channel_id + */ +struct LDKCOption_u64Z ChannelDetails_get_inbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * An optional [`short_channel_id`] alias for this channel, randomly generated by our + * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our + * counterparty will recognize the alias provided here in place of the [`short_channel_id`] + * when they see a payment to be routed to us. + * + * Our counterparty may choose to rotate this value at any time, though will always recognize + * previous values for inbound payment forwarding. + * + * [`short_channel_id`]: Self::short_channel_id + */ +void ChannelDetails_set_inbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The value, in satoshis, of this channel as appears in the funding output + */ +uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The value, in satoshis, of this channel as appears in the funding output + */ +void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The value, in satoshis, that must always be held in the channel for us. This value ensures + * that if we broadcast a revoked state, our counterparty can punish us by claiming at least + * this value on chain. + * + * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat + */ +struct LDKCOption_u64Z ChannelDetails_get_unspendable_punishment_reserve(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The value, in satoshis, that must always be held in the channel for us. This value ensures + * that if we broadcast a revoked state, our counterparty can punish us by claiming at least + * this value on chain. + * + * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat + */ +void ChannelDetails_set_unspendable_punishment_reserve(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. This may be zero for objects + * serialized with LDK versions prior to 0.0.113. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + */ +struct LDKU128 ChannelDetails_get_user_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. This may be zero for objects + * serialized with LDK versions prior to 0.0.113. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + */ +void ChannelDetails_set_user_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKU128 val); + +/** + * The currently negotiated fee rate denominated in satoshi per 1000 weight units, + * which is applied to commitment and HTLC transactions. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. + */ +struct LDKCOption_u32Z ChannelDetails_get_feerate_sat_per_1000_weight(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The currently negotiated fee rate denominated in satoshi per 1000 weight units, + * which is applied to commitment and HTLC transactions. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. + */ +void ChannelDetails_set_feerate_sat_per_1000_weight(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); + +/** + * The available outbound capacity for sending HTLCs to the remote peer. This does not include + * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new outbound HTLCs). This further does not include any pending + * outgoing HTLCs which are awaiting some other resolution to be sent. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we + * should be able to spend nearly this amount. + */ +uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The available outbound capacity for sending HTLCs to the remote peer. This does not include + * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new outbound HTLCs). This further does not include any pending + * outgoing HTLCs which are awaiting some other resolution to be sent. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we + * should be able to spend nearly this amount. + */ +void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The available outbound capacity for sending a single HTLC to the remote peer. This is + * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by + * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us + * to use a limit as close as possible to the HTLC limit we can currently send. + * + * See also [`ChannelDetails::next_outbound_htlc_minimum_msat`] and + * [`ChannelDetails::outbound_capacity_msat`]. + */ +uint64_t ChannelDetails_get_next_outbound_htlc_limit_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The available outbound capacity for sending a single HTLC to the remote peer. This is + * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by + * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us + * to use a limit as close as possible to the HTLC limit we can currently send. + * + * See also [`ChannelDetails::next_outbound_htlc_minimum_msat`] and + * [`ChannelDetails::outbound_capacity_msat`]. + */ +void ChannelDetails_set_next_outbound_htlc_limit_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The minimum value for sending a single HTLC to the remote peer. This is the equivalent of + * [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than + * an upper-bound. This is intended for use when routing, allowing us to ensure we pick a + * route which is valid. + */ +uint64_t ChannelDetails_get_next_outbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The minimum value for sending a single HTLC to the remote peer. This is the equivalent of + * [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than + * an upper-bound. This is intended for use when routing, allowing us to ensure we pick a + * route which is valid. + */ +void ChannelDetails_set_next_outbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The available inbound capacity for the remote peer to send HTLCs to us. This does not + * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new inbound HTLCs). + * Note that there are some corner cases not fully handled here, so the actual available + * inbound capacity may be slightly higher than this. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. + * However, our counterparty should be able to spend nearly this amount. + */ +uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The available inbound capacity for the remote peer to send HTLCs to us. This does not + * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new inbound HTLCs). + * Note that there are some corner cases not fully handled here, so the actual available + * inbound capacity may be slightly higher than this. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. + * However, our counterparty should be able to spend nearly this amount. + */ +void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The number of required confirmations on the funding transaction before the funding will be + * considered \"locked\". This number is selected by the channel fundee (i.e. us if + * [`is_outbound`] is *not* set), and can be selected for inbound channels with + * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with + * [`ChannelHandshakeLimits::max_minimum_depth`]. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`is_outbound`]: ChannelDetails::is_outbound + * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth + * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + */ +struct LDKCOption_u32Z ChannelDetails_get_confirmations_required(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The number of required confirmations on the funding transaction before the funding will be + * considered \"locked\". This number is selected by the channel fundee (i.e. us if + * [`is_outbound`] is *not* set), and can be selected for inbound channels with + * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with + * [`ChannelHandshakeLimits::max_minimum_depth`]. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`is_outbound`]: ChannelDetails::is_outbound + * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth + * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + */ +void ChannelDetails_set_confirmations_required(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); + +/** + * The current number of confirmations on the funding transaction. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. + */ +struct LDKCOption_u32Z ChannelDetails_get_confirmations(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The current number of confirmations on the funding transaction. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. + */ +void ChannelDetails_set_confirmations(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); + +/** + * The number of blocks (after our commitment transaction confirms) that we will need to wait + * until we can claim our funds after we force-close the channel. During this time our + * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty + * force-closes the channel and broadcasts a commitment transaction we do not have to wait any + * time to claim our non-HTLC-encumbered funds. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + */ +struct LDKCOption_u16Z ChannelDetails_get_force_close_spend_delay(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The number of blocks (after our commitment transaction confirms) that we will need to wait + * until we can claim our funds after we force-close the channel. During this time our + * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty + * force-closes the channel and broadcasts a commitment transaction we do not have to wait any + * time to claim our non-HTLC-encumbered funds. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + */ +void ChannelDetails_set_force_close_spend_delay(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); + +/** + * True if the channel was initiated (and thus funded) by us. + */ +bool ChannelDetails_get_is_outbound(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * True if the channel was initiated (and thus funded) by us. + */ +void ChannelDetails_set_is_outbound(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); + +/** + * True if the channel is confirmed, channel_ready messages have been exchanged, and the + * channel is not currently being shut down. `channel_ready` message exchange implies the + * required confirmation count has been reached (and we were connected to the peer at some + * point after the funding transaction received enough confirmations). The required + * confirmation count is provided in [`confirmations_required`]. + * + * [`confirmations_required`]: ChannelDetails::confirmations_required + */ +bool ChannelDetails_get_is_channel_ready(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * True if the channel is confirmed, channel_ready messages have been exchanged, and the + * channel is not currently being shut down. `channel_ready` message exchange implies the + * required confirmation count has been reached (and we were connected to the peer at some + * point after the funding transaction received enough confirmations). The required + * confirmation count is provided in [`confirmations_required`]. + * + * [`confirmations_required`]: ChannelDetails::confirmations_required + */ +void ChannelDetails_set_is_channel_ready(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); + +/** + * The stage of the channel's shutdown. + * `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. + * + * Returns a copy of the field. + */ +struct LDKCOption_ChannelShutdownStateZ ChannelDetails_get_channel_shutdown_state(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The stage of the channel's shutdown. + * `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. + */ +void ChannelDetails_set_channel_shutdown_state(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_ChannelShutdownStateZ val); + +/** + * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) + * the peer is connected, and (c) the channel is not currently negotiating a shutdown. + * + * This is a strict superset of `is_channel_ready`. + */ +bool ChannelDetails_get_is_usable(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) + * the peer is connected, and (c) the channel is not currently negotiating a shutdown. + * + * This is a strict superset of `is_channel_ready`. + */ +void ChannelDetails_set_is_usable(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); + +/** + * True if this channel is (or will be) publicly-announced. + */ +bool ChannelDetails_get_is_announced(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * True if this channel is (or will be) publicly-announced. + */ +void ChannelDetails_set_is_announced(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); + +/** + * The smallest value HTLC (in msat) we will accept, for this channel. This field + * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 + */ +struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The smallest value HTLC (in msat) we will accept, for this channel. This field + * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 + */ +void ChannelDetails_set_inbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The largest value HTLC (in msat) we currently will accept, for this channel. + */ +struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_maximum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The largest value HTLC (in msat) we currently will accept, for this channel. + */ +void ChannelDetails_set_inbound_htlc_maximum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * Set of configurable parameters that affect channel operation. + * + * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelConfig ChannelDetails_get_config(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * Set of configurable parameters that affect channel operation. + * + * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChannelDetails_set_config(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelConfig val); + +/** + * Pending inbound HTLCs. + * + * This field is empty for objects serialized with LDK versions prior to 0.0.122. + */ +struct LDKCVec_InboundHTLCDetailsZ ChannelDetails_get_pending_inbound_htlcs(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * Pending inbound HTLCs. + * + * This field is empty for objects serialized with LDK versions prior to 0.0.122. + */ +void ChannelDetails_set_pending_inbound_htlcs(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCVec_InboundHTLCDetailsZ val); + +/** + * Pending outbound HTLCs. + * + * This field is empty for objects serialized with LDK versions prior to 0.0.122. + */ +struct LDKCVec_OutboundHTLCDetailsZ ChannelDetails_get_pending_outbound_htlcs(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * Pending outbound HTLCs. + * + * This field is empty for objects serialized with LDK versions prior to 0.0.122. + */ +void ChannelDetails_set_pending_outbound_htlcs(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCVec_OutboundHTLCDetailsZ val); + +/** + * Constructs a new ChannelDetails given each field + * + * Note that funding_txo_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that config_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKChannelId channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKChannelTypeFeatures channel_type_arg, struct LDKCOption_u64Z short_channel_id_arg, struct LDKCOption_u64Z outbound_scid_alias_arg, struct LDKCOption_u64Z inbound_scid_alias_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, struct LDKU128 user_channel_id_arg, struct LDKCOption_u32Z feerate_sat_per_1000_weight_arg, uint64_t outbound_capacity_msat_arg, uint64_t next_outbound_htlc_limit_msat_arg, uint64_t next_outbound_htlc_minimum_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u32Z confirmations_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_channel_ready_arg, struct LDKCOption_ChannelShutdownStateZ channel_shutdown_state_arg, bool is_usable_arg, bool is_announced_arg, struct LDKCOption_u64Z inbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z inbound_htlc_maximum_msat_arg, struct LDKChannelConfig config_arg, struct LDKCVec_InboundHTLCDetailsZ pending_inbound_htlcs_arg, struct LDKCVec_OutboundHTLCDetailsZ pending_outbound_htlcs_arg); + +/** + * Creates a copy of the ChannelDetails + */ +struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); + +/** + * Gets the current SCID which should be used to identify this channel for inbound payments. + * This should be used for providing invoice hints or in any other context where our + * counterparty will forward a payment to us. + * + * This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the + * [`ChannelDetails::short_channel_id`]. See those for more information. + */ +MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_inbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); + +/** + * Gets the current SCID which should be used to identify this channel for outbound payments. + * This should be used in [`Route`]s to describe the first hop or in other contexts where + * we're sending or forwarding a payment outbound over this channel. + * + * This is either the [`ChannelDetails::short_channel_id`], if set, or the + * [`ChannelDetails::outbound_scid_alias`]. See those for more information. + * + * [`Route`]: crate::routing::router::Route + */ +MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_outbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); + +/** + * Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read + */ +struct LDKCVec_u8Z ChannelDetails_write(const struct LDKChannelDetails *NONNULL_PTR obj); + +/** + * Read a ChannelDetails from a byte array, created by ChannelDetails_write + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ ChannelDetails_read(struct LDKu8slice ser); + +/** + * Creates a copy of the ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_clone(const enum LDKChannelShutdownState *NONNULL_PTR orig); + +/** + * Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_not_shutting_down(void); + +/** + * Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_shutdown_initiated(void); + +/** + * Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_resolving_htlcs(void); + +/** + * Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_negotiating_closing_fee(void); + +/** + * Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_shutdown_complete(void); + +/** + * Checks if two ChannelShutdownStates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool ChannelShutdownState_eq(const enum LDKChannelShutdownState *NONNULL_PTR a, const enum LDKChannelShutdownState *NONNULL_PTR b); + +/** + * Serialize the ChannelShutdownState object into a byte array which can be read by ChannelShutdownState_read + */ +struct LDKCVec_u8Z ChannelShutdownState_write(const enum LDKChannelShutdownState *NONNULL_PTR obj); + +/** + * Read a ChannelShutdownState from a byte array, created by ChannelShutdownState_write + */ +struct LDKCResult_ChannelShutdownStateDecodeErrorZ ChannelShutdownState_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the ExpandedKey, if is_owned is set and inner is non-NULL. + */ +void ExpandedKey_free(struct LDKExpandedKey this_obj); + +/** + * Generates a non-cryptographic 64-bit hash of the ExpandedKey. + */ +uint64_t ExpandedKey_hash(const struct LDKExpandedKey *NONNULL_PTR o); + +/** + * Creates a copy of the ExpandedKey + */ +struct LDKExpandedKey ExpandedKey_clone(const struct LDKExpandedKey *NONNULL_PTR orig); + +/** + * Checks if two ExpandedKeys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool ExpandedKey_eq(const struct LDKExpandedKey *NONNULL_PTR a, const struct LDKExpandedKey *NONNULL_PTR b); + +/** + * Create a new [`ExpandedKey`] for generating an inbound payment hash and secret. + * + * It is recommended to cache this value and not regenerate it for each new inbound payment. + */ +MUST_USE_RES struct LDKExpandedKey ExpandedKey_new(struct LDKThirtyTwoBytes key_material); + +/** + * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no + * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without + * a `ChannelManager`. + * + * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key`]. It is recommended to + * cache this value and not regenerate it for each new inbound payment. + * + * `current_time` is a Unix timestamp representing the current time. + * + * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable + * on versions of LDK prior to 0.0.114. + * + * [phantom node payments]: crate::sign::PhantomKeysManager + * [`NodeSigner::get_inbound_payment_key`]: crate::sign::NodeSigner::get_inbound_payment_key + */ +struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ create(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, const struct LDKEntropySource *NONNULL_PTR entropy_source, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); + +/** + * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`], + * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments] + * without a `ChannelManager`. + * + * See [`create`] for information on the `keys` and `current_time` parameters. + * + * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable + * on versions of LDK prior to 0.0.114. + * + * [phantom node payments]: crate::sign::PhantomKeysManager + */ +struct LDKCResult_ThirtyTwoBytesNoneZ create_from_hash(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, struct LDKThirtyTwoBytes payment_hash, uint32_t invoice_expiry_delta_secs, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); + +/** + * Frees any resources used by the DecodeError + */ +void DecodeError_free(struct LDKDecodeError this_ptr); + +/** + * Creates a copy of the DecodeError + */ +struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); + +/** + * Utility method to constructs a new UnknownVersion-variant DecodeError + */ +struct LDKDecodeError DecodeError_unknown_version(void); + +/** + * Utility method to constructs a new UnknownRequiredFeature-variant DecodeError + */ +struct LDKDecodeError DecodeError_unknown_required_feature(void); + +/** + * Utility method to constructs a new InvalidValue-variant DecodeError + */ +struct LDKDecodeError DecodeError_invalid_value(void); + +/** + * Utility method to constructs a new ShortRead-variant DecodeError + */ +struct LDKDecodeError DecodeError_short_read(void); + +/** + * Utility method to constructs a new BadLengthDescriptor-variant DecodeError + */ +struct LDKDecodeError DecodeError_bad_length_descriptor(void); + +/** + * Utility method to constructs a new Io-variant DecodeError + */ +struct LDKDecodeError DecodeError_io(enum LDKIOError a); + +/** + * Utility method to constructs a new UnsupportedCompression-variant DecodeError + */ +struct LDKDecodeError DecodeError_unsupported_compression(void); + +/** + * Utility method to constructs a new DangerousValue-variant DecodeError + */ +struct LDKDecodeError DecodeError_dangerous_value(void); + +/** + * Generates a non-cryptographic 64-bit hash of the DecodeError. + */ +uint64_t DecodeError_hash(const struct LDKDecodeError *NONNULL_PTR o); + +/** + * Checks if two DecodeErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool DecodeError_eq(const struct LDKDecodeError *NONNULL_PTR a, const struct LDKDecodeError *NONNULL_PTR b); + +/** + * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. + */ +void Init_free(struct LDKInit this_obj); + +/** + * The relevant features which the sender supports. + */ +struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ptr); + +/** + * The relevant features which the sender supports. + */ +void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); + +/** + * Indicates chains the sender is interested in. + * + * If there are no common chains, the connection will be closed. + * + * Returns a copy of the field. + */ +struct LDKCOption_CVec_ThirtyTwoBytesZZ Init_get_networks(const struct LDKInit *NONNULL_PTR this_ptr); + +/** + * Indicates chains the sender is interested in. + * + * If there are no common chains, the connection will be closed. + */ +void Init_set_networks(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_CVec_ThirtyTwoBytesZZ val); + +/** + * The receipient's network address. + * + * This adds the option to report a remote IP address back to a connecting peer using the init + * message. A node can decide to use that information to discover a potential update to its + * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing + * the new address. + */ +struct LDKCOption_SocketAddressZ Init_get_remote_network_address(const struct LDKInit *NONNULL_PTR this_ptr); + +/** + * The receipient's network address. + * + * This adds the option to report a remote IP address back to a connecting peer using the init + * message. A node can decide to use that information to discover a potential update to its + * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing + * the new address. + */ +void Init_set_remote_network_address(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_SocketAddressZ val); + +/** + * Constructs a new Init given each field + */ +MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg, struct LDKCOption_CVec_ThirtyTwoBytesZZ networks_arg, struct LDKCOption_SocketAddressZ remote_network_address_arg); + +/** + * Creates a copy of the Init + */ +struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the Init. + */ +uint64_t Init_hash(const struct LDKInit *NONNULL_PTR o); + +/** + * Checks if two Inits contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool Init_eq(const struct LDKInit *NONNULL_PTR a, const struct LDKInit *NONNULL_PTR b); + +/** + * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. + */ +void ErrorMessage_free(struct LDKErrorMessage this_obj); + +/** + * The channel ID involved in the error. + * + * All-0s indicates a general error unrelated to a specific channel, after which all channels + * with the sending peer should be closed. + */ +struct LDKChannelId ErrorMessage_get_channel_id(const struct LDKErrorMessage *NONNULL_PTR this_ptr); + +/** + * The channel ID involved in the error. + * + * All-0s indicates a general error unrelated to a specific channel, after which all channels + * with the sending peer should be closed. + */ +void ErrorMessage_set_channel_id(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * A possibly human-readable error description. + * + * The string should be sanitized before it is used (e.g., emitted to logs or printed to + * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. + */ +struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR this_ptr); + +/** + * A possibly human-readable error description. + * + * The string should be sanitized before it is used (e.g., emitted to logs or printed to + * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. + */ +void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKStr val); + +/** + * Constructs a new ErrorMessage given each field + */ +MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKChannelId channel_id_arg, struct LDKStr data_arg); + +/** + * Creates a copy of the ErrorMessage + */ +struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the ErrorMessage. + */ +uint64_t ErrorMessage_hash(const struct LDKErrorMessage *NONNULL_PTR o); + +/** + * Checks if two ErrorMessages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool ErrorMessage_eq(const struct LDKErrorMessage *NONNULL_PTR a, const struct LDKErrorMessage *NONNULL_PTR b); + +/** + * Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL. + */ +void WarningMessage_free(struct LDKWarningMessage this_obj); + +/** + * The channel ID involved in the warning. + * + * All-0s indicates a warning unrelated to a specific channel. + */ +struct LDKChannelId WarningMessage_get_channel_id(const struct LDKWarningMessage *NONNULL_PTR this_ptr); + +/** + * The channel ID involved in the warning. + * + * All-0s indicates a warning unrelated to a specific channel. + */ +void WarningMessage_set_channel_id(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * A possibly human-readable warning description. + * + * The string should be sanitized before it is used (e.g. emitted to logs or printed to + * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. + */ +struct LDKStr WarningMessage_get_data(const struct LDKWarningMessage *NONNULL_PTR this_ptr); + +/** + * A possibly human-readable warning description. + * + * The string should be sanitized before it is used (e.g. emitted to logs or printed to + * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. + */ +void WarningMessage_set_data(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKStr val); + +/** + * Constructs a new WarningMessage given each field + */ +MUST_USE_RES struct LDKWarningMessage WarningMessage_new(struct LDKChannelId channel_id_arg, struct LDKStr data_arg); + +/** + * Creates a copy of the WarningMessage + */ +struct LDKWarningMessage WarningMessage_clone(const struct LDKWarningMessage *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the WarningMessage. + */ +uint64_t WarningMessage_hash(const struct LDKWarningMessage *NONNULL_PTR o); + +/** + * Checks if two WarningMessages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool WarningMessage_eq(const struct LDKWarningMessage *NONNULL_PTR a, const struct LDKWarningMessage *NONNULL_PTR b); + +/** + * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. + */ +void Ping_free(struct LDKPing this_obj); + +/** + * The desired response length. + */ +uint16_t Ping_get_ponglen(const struct LDKPing *NONNULL_PTR this_ptr); + +/** + * The desired response length. + */ +void Ping_set_ponglen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); + +/** + * The ping packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. + */ +uint16_t Ping_get_byteslen(const struct LDKPing *NONNULL_PTR this_ptr); + +/** + * The ping packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. + */ +void Ping_set_byteslen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); + +/** + * Constructs a new Ping given each field + */ +MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); + +/** + * Creates a copy of the Ping + */ +struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the Ping. + */ +uint64_t Ping_hash(const struct LDKPing *NONNULL_PTR o); + +/** + * Checks if two Pings contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool Ping_eq(const struct LDKPing *NONNULL_PTR a, const struct LDKPing *NONNULL_PTR b); + +/** + * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. + */ +void Pong_free(struct LDKPong this_obj); + +/** + * The pong packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. + */ +uint16_t Pong_get_byteslen(const struct LDKPong *NONNULL_PTR this_ptr); + +/** + * The pong packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. + */ +void Pong_set_byteslen(struct LDKPong *NONNULL_PTR this_ptr, uint16_t val); + +/** + * Constructs a new Pong given each field + */ +MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); + +/** + * Creates a copy of the Pong + */ +struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the Pong. + */ +uint64_t Pong_hash(const struct LDKPong *NONNULL_PTR o); + +/** + * Checks if two Pongs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool Pong_eq(const struct LDKPong *NONNULL_PTR a, const struct LDKPong *NONNULL_PTR b); + +/** + * Frees any resources used by the CommonOpenChannelFields, if is_owned is set and inner is non-NULL. + */ +void CommonOpenChannelFields_free(struct LDKCommonOpenChannelFields this_obj); + +/** + * The genesis hash of the blockchain where the channel is to be opened + */ +const uint8_t (*CommonOpenChannelFields_get_chain_hash(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr))[32]; + +/** + * The genesis hash of the blockchain where the channel is to be opened + */ +void CommonOpenChannelFields_set_chain_hash(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * A temporary channel ID + * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint + * For V1 channels: a temporary channel ID, until the funding outpoint is announced + */ +struct LDKChannelId CommonOpenChannelFields_get_temporary_channel_id(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * A temporary channel ID + * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint + * For V1 channels: a temporary channel ID, until the funding outpoint is announced + */ +void CommonOpenChannelFields_set_temporary_channel_id(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * For V1 channels: The channel value + * For V2 channels: Part of the channel value contributed by the channel initiator + */ +uint64_t CommonOpenChannelFields_get_funding_satoshis(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is - * stored external to LDK. - * - * A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a - * payment secret fetched via this method or [`create_inbound_payment`], and which is at least - * the `min_value_msat` provided here, if one is provided. - * - * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though - * note that LDK will not stop you from registering duplicate payment hashes for inbound - * payments. - * - * `min_value_msat` should be set if the invoice being generated contains a value. Any payment - * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat` - * before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the - * sender \"proof-of-payment\" unless they have paid the required amount. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. This should roughly match the expiry time set in the invoice. - * After this many seconds, we will remove the inbound payment, resulting in any attempts to - * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for - * invoices when no timeout is set. - * - * Note that we use block header time to time-out pending inbound payments (with some margin - * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will - * accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry. - * If you need exact expiry semantics, you should enforce them upon receipt of - * [`PaymentClaimable`]. - * - * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta` - * set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * - * Note that a malicious eavesdropper can intuit whether an inbound payment was created by - * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. - * - * # Note - * - * If you register an inbound payment with this method, then serialize the `ChannelManager`, then - * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. - * - * Errors if `min_value_msat` is greater than total bitcoin supply. - * - * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable - * on versions of LDK prior to 0.0.114. - * - * [`create_inbound_payment`]: Self::create_inbound_payment - * [`PaymentClaimable`]: events::Event::PaymentClaimable + * For V1 channels: The channel value + * For V2 channels: Part of the channel value contributed by the channel initiator */ -MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ ChannelManager_create_inbound_payment_for_hash(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry); +void CommonOpenChannelFields_set_funding_satoshis(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); /** - * Gets an LDK-generated payment preimage from a payment hash and payment secret that were - * previously returned from [`create_inbound_payment`]. - * - * [`create_inbound_payment`]: Self::create_inbound_payment + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted */ -MUST_USE_RES struct LDKCResult_ThirtyTwoBytesAPIErrorZ ChannelManager_get_payment_preimage(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); +uint64_t CommonOpenChannelFields_get_dust_limit_satoshis(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids - * are used when constructing the phantom invoice's route hints. - * - * [phantom node payments]: crate::sign::PhantomKeysManager + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted */ -MUST_USE_RES uint64_t ChannelManager_get_phantom_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); +void CommonOpenChannelFields_set_dust_limit_satoshis(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); /** - * Gets route hints for use in receiving [phantom node payments]. - * - * [phantom node payments]: crate::sign::PhantomKeysManager + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi */ -MUST_USE_RES struct LDKPhantomRouteHints ChannelManager_get_phantom_route_hints(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint64_t CommonOpenChannelFields_get_max_htlc_value_in_flight_msat(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Gets a fake short channel id for use in receiving intercepted payments. These fake scids are - * used when constructing the route hints for HTLCs intended to be intercepted. See - * [`ChannelManager::forward_intercepted_htlc`]. - * - * Note that this method is not guaranteed to return unique values, you may need to call it a few - * times to get a unique scid. + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi */ -MUST_USE_RES uint64_t ChannelManager_get_intercept_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); +void CommonOpenChannelFields_set_max_htlc_value_in_flight_msat(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); /** - * Gets inflight HTLC information by processing pending outbound payments that are in - * our channels. May be used during pathfinding to account for in-use channel liquidity. + * The minimum HTLC size incoming to channel initiator, in milli-satoshi */ -MUST_USE_RES struct LDKInFlightHtlcs ChannelManager_compute_inflight_htlcs(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint64_t CommonOpenChannelFields_get_htlc_minimum_msat(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * The minimum HTLC size incoming to channel initiator, in milli-satoshi */ -struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +void CommonOpenChannelFields_set_htlc_minimum_msat(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new EventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + * The feerate for the commitment transaction set by the channel initiator until updated by + * [`UpdateFee`] */ -struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint32_t CommonOpenChannelFields_get_commitment_feerate_sat_per_1000_weight(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Constructs a new Listen which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is + * The feerate for the commitment transaction set by the channel initiator until updated by + * [`UpdateFee`] */ -struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); +void CommonOpenChannelFields_set_commitment_feerate_sat_per_1000_weight(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint32_t val); /** - * Constructs a new Confirm which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction */ -struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint16_t CommonOpenChannelFields_get_to_self_delay(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Gets a [`Future`] that completes when this [`ChannelManager`] may need to be persisted or - * may have events that need processing. - * - * In order to check if this [`ChannelManager`] needs persisting, call - * [`Self::get_and_clear_needs_persistence`]. - * - * Note that callbacks registered on the [`Future`] MUST NOT call back into this - * [`ChannelManager`] and should instead register actions to be taken later. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction */ -MUST_USE_RES struct LDKFuture ChannelManager_get_event_or_persistence_needed_future(const struct LDKChannelManager *NONNULL_PTR this_arg); +void CommonOpenChannelFields_set_to_self_delay(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint16_t val); /** - * Returns true if this [`ChannelManager`] needs to be persisted. - * - * See [`Self::get_event_or_persistence_needed_future`] for retrieving a [`Future`] that - * indicates this should be checked. + * The maximum number of inbound HTLCs towards channel initiator */ -MUST_USE_RES bool ChannelManager_get_and_clear_needs_persistence(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint16_t CommonOpenChannelFields_get_max_accepted_htlcs(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Gets the latest best block which was connected either via the [`chain::Listen`] or - * [`chain::Confirm`] interfaces. + * The maximum number of inbound HTLCs towards channel initiator */ -MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); +void CommonOpenChannelFields_set_max_accepted_htlcs(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint16_t val); /** - * Fetches the set of [`NodeFeatures`] flags that are provided by or required by - * [`ChannelManager`]. + * The channel initiator's key controlling the funding transaction */ -MUST_USE_RES struct LDKNodeFeatures ChannelManager_node_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKPublicKey CommonOpenChannelFields_get_funding_pubkey(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Fetches the set of [`ChannelFeatures`] flags that are provided by or required by - * [`ChannelManager`]. + * The channel initiator's key controlling the funding transaction */ -MUST_USE_RES struct LDKChannelFeatures ChannelManager_channel_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +void CommonOpenChannelFields_set_funding_pubkey(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Fetches the set of [`ChannelTypeFeatures`] flags that are provided by or required by - * [`ChannelManager`]. + * Used to derive a revocation key for transactions broadcast by counterparty */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelManager_channel_type_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKPublicKey CommonOpenChannelFields_get_revocation_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Fetches the set of [`InitFeatures`] flags that are provided by or required by - * [`ChannelManager`]. + * Used to derive a revocation key for transactions broadcast by counterparty */ -MUST_USE_RES struct LDKInitFeatures ChannelManager_init_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +void CommonOpenChannelFields_set_revocation_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is + * A payment key to channel initiator for transactions broadcast by counterparty */ -struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKPublicKey CommonOpenChannelFields_get_payment_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is + * A payment key to channel initiator for transactions broadcast by counterparty */ -struct LDKOffersMessageHandler ChannelManager_as_OffersMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +void CommonOpenChannelFields_set_payment_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is + * Used to derive a payment key to channel initiator for transactions broadcast by channel + * initiator */ -struct LDKAsyncPaymentsMessageHandler ChannelManager_as_AsyncPaymentsMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKPublicKey CommonOpenChannelFields_get_delayed_payment_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Constructs a new DNSResolverMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned DNSResolverMessageHandler must be freed before this_arg is + * Used to derive a payment key to channel initiator for transactions broadcast by channel + * initiator */ -struct LDKDNSResolverMessageHandler ChannelManager_as_DNSResolverMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +void CommonOpenChannelFields_set_delayed_payment_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is + * Used to derive an HTLC payment key to channel initiator */ -struct LDKNodeIdLookUp ChannelManager_as_NodeIdLookUp(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKPublicKey CommonOpenChannelFields_get_htlc_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Fetches the set of [`InitFeatures`] flags that are provided by or required by - * [`ChannelManager`]. + * Used to derive an HTLC payment key to channel initiator */ -struct LDKInitFeatures provided_init_features(const struct LDKUserConfig *NONNULL_PTR config); +void CommonOpenChannelFields_set_htlc_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read + * The first to-be-broadcast-by-channel-initiator transaction's per commitment point */ -struct LDKCVec_u8Z PhantomRouteHints_write(const struct LDKPhantomRouteHints *NONNULL_PTR obj); +struct LDKPublicKey CommonOpenChannelFields_get_first_per_commitment_point(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write + * The first to-be-broadcast-by-channel-initiator transaction's per commitment point */ -struct LDKCResult_PhantomRouteHintsDecodeErrorZ PhantomRouteHints_read(struct LDKu8slice ser); +void CommonOpenChannelFields_set_first_per_commitment_point(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the BlindedForward object into a byte array which can be read by BlindedForward_read + * The channel flags to be used */ -struct LDKCVec_u8Z BlindedForward_write(const struct LDKBlindedForward *NONNULL_PTR obj); +uint8_t CommonOpenChannelFields_get_channel_flags(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Read a BlindedForward from a byte array, created by BlindedForward_write + * The channel flags to be used */ -struct LDKCResult_BlindedForwardDecodeErrorZ BlindedForward_read(struct LDKu8slice ser); +void CommonOpenChannelFields_set_channel_flags(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint8_t val); /** - * Serialize the PendingHTLCRouting object into a byte array which can be read by PendingHTLCRouting_read + * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we + * collaboratively close */ -struct LDKCVec_u8Z PendingHTLCRouting_write(const struct LDKPendingHTLCRouting *NONNULL_PTR obj); +struct LDKCOption_CVec_u8ZZ CommonOpenChannelFields_get_shutdown_scriptpubkey(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Read a PendingHTLCRouting from a byte array, created by PendingHTLCRouting_write + * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we + * collaboratively close */ -struct LDKCResult_PendingHTLCRoutingDecodeErrorZ PendingHTLCRouting_read(struct LDKu8slice ser); +void CommonOpenChannelFields_set_shutdown_scriptpubkey(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); /** - * Serialize the PendingHTLCInfo object into a byte array which can be read by PendingHTLCInfo_read + * The channel type that this channel will represent + * + * If this is `None`, we derive the channel type from the intersection of our + * feature bits with our counterparty's feature bits from the [`Init`] message. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z PendingHTLCInfo_write(const struct LDKPendingHTLCInfo *NONNULL_PTR obj); +struct LDKChannelTypeFeatures CommonOpenChannelFields_get_channel_type(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); /** - * Read a PendingHTLCInfo from a byte array, created by PendingHTLCInfo_write + * The channel type that this channel will represent + * + * If this is `None`, we derive the channel type from the intersection of our + * feature bits with our counterparty's feature bits from the [`Init`] message. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_PendingHTLCInfoDecodeErrorZ PendingHTLCInfo_read(struct LDKu8slice ser); +void CommonOpenChannelFields_set_channel_type(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * Serialize the BlindedFailure object into a byte array which can be read by BlindedFailure_read + * Constructs a new CommonOpenChannelFields given each field + * + * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z BlindedFailure_write(const enum LDKBlindedFailure *NONNULL_PTR obj); +MUST_USE_RES struct LDKCommonOpenChannelFields CommonOpenChannelFields_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKChannelId temporary_channel_id_arg, uint64_t funding_satoshis_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t commitment_feerate_sat_per_1000_weight_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_basepoint_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, uint8_t channel_flags_arg, struct LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg); /** - * Read a BlindedFailure from a byte array, created by BlindedFailure_write + * Creates a copy of the CommonOpenChannelFields */ -struct LDKCResult_BlindedFailureDecodeErrorZ BlindedFailure_read(struct LDKu8slice ser); +struct LDKCommonOpenChannelFields CommonOpenChannelFields_clone(const struct LDKCommonOpenChannelFields *NONNULL_PTR orig); /** - * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read + * Generates a non-cryptographic 64-bit hash of the CommonOpenChannelFields. */ -struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); +uint64_t CommonOpenChannelFields_hash(const struct LDKCommonOpenChannelFields *NONNULL_PTR o); /** - * Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. + * Checks if two CommonOpenChannelFieldss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_obj); +bool CommonOpenChannelFields_eq(const struct LDKCommonOpenChannelFields *NONNULL_PTR a, const struct LDKCommonOpenChannelFields *NONNULL_PTR b); /** - * A cryptographically secure source of entropy. + * The [`ChannelParameters`] for this channel. */ -const struct LDKEntropySource *ChannelManagerReadArgs_get_entropy_source(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelParameters CommonOpenChannelFields_channel_parameters(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_arg); /** - * A cryptographically secure source of entropy. + * Frees any resources used by the ChannelParameters, if is_owned is set and inner is non-NULL. */ -void ChannelManagerReadArgs_set_entropy_source(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKEntropySource val); +void ChannelParameters_free(struct LDKChannelParameters this_obj); /** - * A signer that is able to perform node-scoped cryptographic operations. + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted. */ -const struct LDKNodeSigner *ChannelManagerReadArgs_get_node_signer(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +uint64_t ChannelParameters_get_dust_limit_satoshis(const struct LDKChannelParameters *NONNULL_PTR this_ptr); /** - * A signer that is able to perform node-scoped cryptographic operations. + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted. */ -void ChannelManagerReadArgs_set_node_signer(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKNodeSigner val); +void ChannelParameters_set_dust_limit_satoshis(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel - * signing data. + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi */ -const struct LDKSignerProvider *ChannelManagerReadArgs_get_signer_provider(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +uint64_t ChannelParameters_get_max_htlc_value_in_flight_msat(const struct LDKChannelParameters *NONNULL_PTR this_ptr); /** - * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel - * signing data. + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi */ -void ChannelManagerReadArgs_set_signer_provider(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKSignerProvider val); +void ChannelParameters_set_max_htlc_value_in_flight_msat(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The fee_estimator for use in the ChannelManager in the future. - * - * No calls to the FeeEstimator will be made during deserialization. + * The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi */ -const struct LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +uint64_t ChannelParameters_get_htlc_minimum_msat(const struct LDKChannelParameters *NONNULL_PTR this_ptr); /** - * The fee_estimator for use in the ChannelManager in the future. - * - * No calls to the FeeEstimator will be made during deserialization. + * The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi */ -void ChannelManagerReadArgs_set_fee_estimator(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKFeeEstimator val); +void ChannelParameters_set_htlc_minimum_msat(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The chain::Watch for use in the ChannelManager in the future. - * - * No calls to the chain::Watch will be made during deserialization. It is assumed that - * you have deserialized ChannelMonitors separately and will add them to your - * chain::Watch after deserializing this ChannelManager. + * The feerate for the commitment transaction set by the channel initiator until updated by + * [`UpdateFee`] */ -const struct LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +uint32_t ChannelParameters_get_commitment_feerate_sat_per_1000_weight(const struct LDKChannelParameters *NONNULL_PTR this_ptr); /** - * The chain::Watch for use in the ChannelManager in the future. - * - * No calls to the chain::Watch will be made during deserialization. It is assumed that - * you have deserialized ChannelMonitors separately and will add them to your - * chain::Watch after deserializing this ChannelManager. + * The feerate for the commitment transaction set by the channel initiator until updated by + * [`UpdateFee`] */ -void ChannelManagerReadArgs_set_chain_monitor(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKWatch val); +void ChannelParameters_set_commitment_feerate_sat_per_1000_weight(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint32_t val); /** - * The BroadcasterInterface which will be used in the ChannelManager in the future and may be - * used to broadcast the latest local commitment transactions of channels which must be - * force-closed during deserialization. + * The number of blocks which the non-channel-initator will have to wait to claim on-chain + * funds if they broadcast a commitment transaction. */ -const struct LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +uint16_t ChannelParameters_get_to_self_delay(const struct LDKChannelParameters *NONNULL_PTR this_ptr); /** - * The BroadcasterInterface which will be used in the ChannelManager in the future and may be - * used to broadcast the latest local commitment transactions of channels which must be - * force-closed during deserialization. + * The number of blocks which the non-channel-initator will have to wait to claim on-chain + * funds if they broadcast a commitment transaction. */ -void ChannelManagerReadArgs_set_tx_broadcaster(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKBroadcasterInterface val); +void ChannelParameters_set_to_self_delay(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint16_t val); /** - * The router which will be used in the ChannelManager in the future for finding routes - * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. - * - * No calls to the router will be made during deserialization. + * The maximum number of pending HTLCs towards the channel initiator. */ -const struct LDKRouter *ChannelManagerReadArgs_get_router(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +uint16_t ChannelParameters_get_max_accepted_htlcs(const struct LDKChannelParameters *NONNULL_PTR this_ptr); /** - * The router which will be used in the ChannelManager in the future for finding routes - * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. - * - * No calls to the router will be made during deserialization. + * The maximum number of pending HTLCs towards the channel initiator. */ -void ChannelManagerReadArgs_set_router(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKRouter val); +void ChannelParameters_set_max_accepted_htlcs(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint16_t val); /** - * The [`MessageRouter`] used for constructing [`BlindedMessagePath`]s for [`Offer`]s, - * [`Refund`]s, and any reply paths. + * Constructs a new ChannelParameters given each field */ -const struct LDKMessageRouter *ChannelManagerReadArgs_get_message_router(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelParameters ChannelParameters_new(uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t commitment_feerate_sat_per_1000_weight_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg); /** - * The [`MessageRouter`] used for constructing [`BlindedMessagePath`]s for [`Offer`]s, - * [`Refund`]s, and any reply paths. + * Creates a copy of the ChannelParameters */ -void ChannelManagerReadArgs_set_message_router(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKMessageRouter val); +struct LDKChannelParameters ChannelParameters_clone(const struct LDKChannelParameters *NONNULL_PTR orig); /** - * The Logger for use in the ChannelManager and which may be used to log information during - * deserialization. + * Generates a non-cryptographic 64-bit hash of the ChannelParameters. */ -const struct LDKLogger *ChannelManagerReadArgs_get_logger(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +uint64_t ChannelParameters_hash(const struct LDKChannelParameters *NONNULL_PTR o); /** - * The Logger for use in the ChannelManager and which may be used to log information during - * deserialization. + * Checks if two ChannelParameterss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelManagerReadArgs_set_logger(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKLogger val); +bool ChannelParameters_eq(const struct LDKChannelParameters *NONNULL_PTR a, const struct LDKChannelParameters *NONNULL_PTR b); /** - * Default settings used for new channels. Any existing channels will continue to use the - * runtime settings which were stored when the ChannelManager was serialized. + * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. */ -struct LDKUserConfig ChannelManagerReadArgs_get_default_config(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void OpenChannel_free(struct LDKOpenChannel this_obj); /** - * Default settings used for new channels. Any existing channels will continue to use the - * runtime settings which were stored when the ChannelManager was serialized. + * Common fields of `open_channel(2)`-like messages */ -void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKUserConfig val); +struct LDKCommonOpenChannelFields OpenChannel_get_common_fields(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Simple utility function to create a ChannelManagerReadArgs which creates the monitor - * HashMap for you. This is primarily useful for C bindings where it is not practical to - * populate a HashMap directly from C. + * Common fields of `open_channel(2)`-like messages */ -MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKSignerProvider signer_provider, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKRouter router, struct LDKMessageRouter message_router, struct LDKLogger logger, struct LDKUserConfig default_config, struct LDKCVec_ChannelMonitorZ channel_monitors); +void OpenChannel_set_common_fields(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKCommonOpenChannelFields val); /** - * Read a C2Tuple_ThirtyTwoBytesChannelManagerZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelManagerZ_write + * The amount to push to the counterparty as part of the open, in milli-satoshi */ -struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ C2Tuple_ThirtyTwoBytesChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg); +uint64_t OpenChannel_get_push_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Frees any resources used by the DelayedPaymentBasepoint, if is_owned is set and inner is non-NULL. + * The amount to push to the counterparty as part of the open, in milli-satoshi */ -void DelayedPaymentBasepoint_free(struct LDKDelayedPaymentBasepoint this_obj); +void OpenChannel_set_push_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); -struct LDKPublicKey DelayedPaymentBasepoint_get_a(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_ptr); +/** + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + */ +uint64_t OpenChannel_get_channel_reserve_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); -void DelayedPaymentBasepoint_set_a(struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + */ +void OpenChannel_set_channel_reserve_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new DelayedPaymentBasepoint given each field + * Constructs a new OpenChannel given each field */ -MUST_USE_RES struct LDKDelayedPaymentBasepoint DelayedPaymentBasepoint_new(struct LDKPublicKey a_arg); +MUST_USE_RES struct LDKOpenChannel OpenChannel_new(struct LDKCommonOpenChannelFields common_fields_arg, uint64_t push_msat_arg, uint64_t channel_reserve_satoshis_arg); /** - * Checks if two DelayedPaymentBasepoints contain equal inner contents. + * Creates a copy of the OpenChannel + */ +struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the OpenChannel. + */ +uint64_t OpenChannel_hash(const struct LDKOpenChannel *NONNULL_PTR o); + +/** + * Checks if two OpenChannels contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool DelayedPaymentBasepoint_eq(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR a, const struct LDKDelayedPaymentBasepoint *NONNULL_PTR b); +bool OpenChannel_eq(const struct LDKOpenChannel *NONNULL_PTR a, const struct LDKOpenChannel *NONNULL_PTR b); /** - * Creates a copy of the DelayedPaymentBasepoint + * Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL. */ -struct LDKDelayedPaymentBasepoint DelayedPaymentBasepoint_clone(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR orig); +void OpenChannelV2_free(struct LDKOpenChannelV2 this_obj); /** - * Generates a non-cryptographic 64-bit hash of the DelayedPaymentBasepoint. + * Common fields of `open_channel(2)`-like messages */ -uint64_t DelayedPaymentBasepoint_hash(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR o); +struct LDKCommonOpenChannelFields OpenChannelV2_get_common_fields(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Get inner Public Key + * Common fields of `open_channel(2)`-like messages */ -MUST_USE_RES struct LDKPublicKey DelayedPaymentBasepoint_to_public_key(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_arg); +void OpenChannelV2_set_common_fields(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKCommonOpenChannelFields val); /** - *Derives the \"tweak\" used in calculate [`DelayedPaymentKey::from_basepoint`].\n\n[`DelayedPaymentKey::from_basepoint`] calculates a private key as:\n`privkey = basepoint_secret + SHA256(per_commitment_point || basepoint)`\n\nThis calculates the hash part in the tweak derivation process, which is used to\nensure that each key is unique and cannot be guessed by an external party. + * The feerate for the funding transaction set by the channel initiator */ -MUST_USE_RES struct LDKThirtyTwoBytes DelayedPaymentBasepoint_derive_add_tweak(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_arg, struct LDKPublicKey per_commitment_point); +uint32_t OpenChannelV2_get_funding_feerate_sat_per_1000_weight(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Serialize the DelayedPaymentBasepoint object into a byte array which can be read by DelayedPaymentBasepoint_read + * The feerate for the funding transaction set by the channel initiator */ -struct LDKCVec_u8Z DelayedPaymentBasepoint_write(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR obj); +void OpenChannelV2_set_funding_feerate_sat_per_1000_weight(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); /** - * Read a DelayedPaymentBasepoint from a byte array, created by DelayedPaymentBasepoint_write + * The locktime for the funding transaction */ -struct LDKCResult_DelayedPaymentBasepointDecodeErrorZ DelayedPaymentBasepoint_read(struct LDKu8slice ser); +uint32_t OpenChannelV2_get_locktime(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Frees any resources used by the DelayedPaymentKey, if is_owned is set and inner is non-NULL. + * The locktime for the funding transaction */ -void DelayedPaymentKey_free(struct LDKDelayedPaymentKey this_obj); +void OpenChannelV2_set_locktime(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); -struct LDKPublicKey DelayedPaymentKey_get_a(const struct LDKDelayedPaymentKey *NONNULL_PTR this_ptr); +/** + * The second to-be-broadcast-by-channel-initiator transaction's per commitment point + */ +struct LDKPublicKey OpenChannelV2_get_second_per_commitment_point(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); -void DelayedPaymentKey_set_a(struct LDKDelayedPaymentKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * The second to-be-broadcast-by-channel-initiator transaction's per commitment point + */ +void OpenChannelV2_set_second_per_commitment_point(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new DelayedPaymentKey given each field + * Optionally, a requirement that only confirmed inputs can be added */ -MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_new(struct LDKPublicKey a_arg); +enum LDKCOption_NoneZ OpenChannelV2_get_require_confirmed_inputs(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Checks if two DelayedPaymentKeys contain equal inner contents. + * Optionally, a requirement that only confirmed inputs can be added + */ +void OpenChannelV2_set_require_confirmed_inputs(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); + +/** + * Constructs a new OpenChannelV2 given each field + */ +MUST_USE_RES struct LDKOpenChannelV2 OpenChannelV2_new(struct LDKCommonOpenChannelFields common_fields_arg, uint32_t funding_feerate_sat_per_1000_weight_arg, uint32_t locktime_arg, struct LDKPublicKey second_per_commitment_point_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); + +/** + * Creates a copy of the OpenChannelV2 + */ +struct LDKOpenChannelV2 OpenChannelV2_clone(const struct LDKOpenChannelV2 *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the OpenChannelV2. + */ +uint64_t OpenChannelV2_hash(const struct LDKOpenChannelV2 *NONNULL_PTR o); + +/** + * Checks if two OpenChannelV2s contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool DelayedPaymentKey_eq(const struct LDKDelayedPaymentKey *NONNULL_PTR a, const struct LDKDelayedPaymentKey *NONNULL_PTR b); +bool OpenChannelV2_eq(const struct LDKOpenChannelV2 *NONNULL_PTR a, const struct LDKOpenChannelV2 *NONNULL_PTR b); + +/** + * Frees any resources used by the CommonAcceptChannelFields, if is_owned is set and inner is non-NULL. + */ +void CommonAcceptChannelFields_free(struct LDKCommonAcceptChannelFields this_obj); + +/** + * The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message. + */ +struct LDKChannelId CommonAcceptChannelFields_get_temporary_channel_id(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message. + */ +void CommonAcceptChannelFields_set_temporary_channel_id(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * The threshold below which outputs on transactions broadcast by the channel acceptor will be + * omitted + */ +uint64_t CommonAcceptChannelFields_get_dust_limit_satoshis(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * The threshold below which outputs on transactions broadcast by the channel acceptor will be + * omitted + */ +void CommonAcceptChannelFields_set_dust_limit_satoshis(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + */ +uint64_t CommonAcceptChannelFields_get_max_htlc_value_in_flight_msat(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - * Creates a copy of the DelayedPaymentKey + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -struct LDKDelayedPaymentKey DelayedPaymentKey_clone(const struct LDKDelayedPaymentKey *NONNULL_PTR orig); +void CommonAcceptChannelFields_set_max_htlc_value_in_flight_msat(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint64_t val); /** - *Derive a public delayedpubkey using one node\'s `per_commitment_point` and its countersignatory\'s `basepoint` + * The minimum HTLC size incoming to channel acceptor, in milli-satoshi */ -MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_from_basepoint(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); +uint64_t CommonAcceptChannelFields_get_htlc_minimum_msat(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - *Build a delayedpubkey directly from an already-derived private key + * The minimum HTLC size incoming to channel acceptor, in milli-satoshi */ -MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_from_secret_key(const uint8_t (*sk)[32]); +void CommonAcceptChannelFields_set_htlc_minimum_msat(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint64_t val); /** - * Get inner Public Key + * Minimum depth of the funding transaction before the channel is considered open */ -MUST_USE_RES struct LDKPublicKey DelayedPaymentKey_to_public_key(const struct LDKDelayedPaymentKey *NONNULL_PTR this_arg); +uint32_t CommonAcceptChannelFields_get_minimum_depth(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - * Serialize the DelayedPaymentKey object into a byte array which can be read by DelayedPaymentKey_read + * Minimum depth of the funding transaction before the channel is considered open */ -struct LDKCVec_u8Z DelayedPaymentKey_write(const struct LDKDelayedPaymentKey *NONNULL_PTR obj); +void CommonAcceptChannelFields_set_minimum_depth(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint32_t val); /** - * Read a DelayedPaymentKey from a byte array, created by DelayedPaymentKey_write + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction */ -struct LDKCResult_DelayedPaymentKeyDecodeErrorZ DelayedPaymentKey_read(struct LDKu8slice ser); +uint16_t CommonAcceptChannelFields_get_to_self_delay(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - * Frees any resources used by the HtlcBasepoint, if is_owned is set and inner is non-NULL. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction */ -void HtlcBasepoint_free(struct LDKHtlcBasepoint this_obj); - -struct LDKPublicKey HtlcBasepoint_get_a(const struct LDKHtlcBasepoint *NONNULL_PTR this_ptr); - -void HtlcBasepoint_set_a(struct LDKHtlcBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void CommonAcceptChannelFields_set_to_self_delay(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint16_t val); /** - * Constructs a new HtlcBasepoint given each field + * The maximum number of inbound HTLCs towards channel acceptor */ -MUST_USE_RES struct LDKHtlcBasepoint HtlcBasepoint_new(struct LDKPublicKey a_arg); +uint16_t CommonAcceptChannelFields_get_max_accepted_htlcs(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - * Checks if two HtlcBasepoints contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The maximum number of inbound HTLCs towards channel acceptor */ -bool HtlcBasepoint_eq(const struct LDKHtlcBasepoint *NONNULL_PTR a, const struct LDKHtlcBasepoint *NONNULL_PTR b); +void CommonAcceptChannelFields_set_max_accepted_htlcs(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a copy of the HtlcBasepoint + * The channel acceptor's key controlling the funding transaction */ -struct LDKHtlcBasepoint HtlcBasepoint_clone(const struct LDKHtlcBasepoint *NONNULL_PTR orig); +struct LDKPublicKey CommonAcceptChannelFields_get_funding_pubkey(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the HtlcBasepoint. + * The channel acceptor's key controlling the funding transaction */ -uint64_t HtlcBasepoint_hash(const struct LDKHtlcBasepoint *NONNULL_PTR o); +void CommonAcceptChannelFields_set_funding_pubkey(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Get inner Public Key + * Used to derive a revocation key for transactions broadcast by counterparty */ -MUST_USE_RES struct LDKPublicKey HtlcBasepoint_to_public_key(const struct LDKHtlcBasepoint *NONNULL_PTR this_arg); +struct LDKPublicKey CommonAcceptChannelFields_get_revocation_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - *Derives the \"tweak\" used in calculate [`HtlcKey::from_basepoint`].\n\n[`HtlcKey::from_basepoint`] calculates a private key as:\n`privkey = basepoint_secret + SHA256(per_commitment_point || basepoint)`\n\nThis calculates the hash part in the tweak derivation process, which is used to\nensure that each key is unique and cannot be guessed by an external party. + * Used to derive a revocation key for transactions broadcast by counterparty */ -MUST_USE_RES struct LDKThirtyTwoBytes HtlcBasepoint_derive_add_tweak(const struct LDKHtlcBasepoint *NONNULL_PTR this_arg, struct LDKPublicKey per_commitment_point); +void CommonAcceptChannelFields_set_revocation_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the HtlcBasepoint object into a byte array which can be read by HtlcBasepoint_read + * A payment key to channel acceptor for transactions broadcast by counterparty */ -struct LDKCVec_u8Z HtlcBasepoint_write(const struct LDKHtlcBasepoint *NONNULL_PTR obj); +struct LDKPublicKey CommonAcceptChannelFields_get_payment_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - * Read a HtlcBasepoint from a byte array, created by HtlcBasepoint_write + * A payment key to channel acceptor for transactions broadcast by counterparty */ -struct LDKCResult_HtlcBasepointDecodeErrorZ HtlcBasepoint_read(struct LDKu8slice ser); +void CommonAcceptChannelFields_set_payment_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Frees any resources used by the HtlcKey, if is_owned is set and inner is non-NULL. + * Used to derive a payment key to channel acceptor for transactions broadcast by channel + * acceptor */ -void HtlcKey_free(struct LDKHtlcKey this_obj); - -struct LDKPublicKey HtlcKey_get_a(const struct LDKHtlcKey *NONNULL_PTR this_ptr); - -void HtlcKey_set_a(struct LDKHtlcKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKPublicKey CommonAcceptChannelFields_get_delayed_payment_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - * Constructs a new HtlcKey given each field + * Used to derive a payment key to channel acceptor for transactions broadcast by channel + * acceptor */ -MUST_USE_RES struct LDKHtlcKey HtlcKey_new(struct LDKPublicKey a_arg); +void CommonAcceptChannelFields_set_delayed_payment_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Checks if two HtlcKeys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty */ -bool HtlcKey_eq(const struct LDKHtlcKey *NONNULL_PTR a, const struct LDKHtlcKey *NONNULL_PTR b); +struct LDKPublicKey CommonAcceptChannelFields_get_htlc_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - * Creates a copy of the HtlcKey + * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty */ -struct LDKHtlcKey HtlcKey_clone(const struct LDKHtlcKey *NONNULL_PTR orig); +void CommonAcceptChannelFields_set_htlc_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - *Derive a public htlcpubkey using one node\'s `per_commitment_point` and its countersignatory\'s `basepoint` + * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point */ -MUST_USE_RES struct LDKHtlcKey HtlcKey_from_basepoint(const struct LDKHtlcBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); +struct LDKPublicKey CommonAcceptChannelFields_get_first_per_commitment_point(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - *Build a htlcpubkey directly from an already-derived private key + * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point */ -MUST_USE_RES struct LDKHtlcKey HtlcKey_from_secret_key(const uint8_t (*sk)[32]); +void CommonAcceptChannelFields_set_first_per_commitment_point(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Get inner Public Key + * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we + * collaboratively close */ -MUST_USE_RES struct LDKPublicKey HtlcKey_to_public_key(const struct LDKHtlcKey *NONNULL_PTR this_arg); +struct LDKCOption_CVec_u8ZZ CommonAcceptChannelFields_get_shutdown_scriptpubkey(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - * Serialize the HtlcKey object into a byte array which can be read by HtlcKey_read + * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we + * collaboratively close */ -struct LDKCVec_u8Z HtlcKey_write(const struct LDKHtlcKey *NONNULL_PTR obj); +void CommonAcceptChannelFields_set_shutdown_scriptpubkey(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); /** - * Read a HtlcKey from a byte array, created by HtlcKey_write + * The channel type that this channel will represent. If none is set, we derive the channel + * type from the intersection of our feature bits with our counterparty's feature bits from + * the Init message. + * + * This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s + * [`CommonOpenChannelFields::channel_type`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_HtlcKeyDecodeErrorZ HtlcKey_read(struct LDKu8slice ser); +struct LDKChannelTypeFeatures CommonAcceptChannelFields_get_channel_type(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); /** - * Adds a tweak to a public key to derive a new public key. + * The channel type that this channel will represent. If none is set, we derive the channel + * type from the intersection of our feature bits with our counterparty's feature bits from + * the Init message. * - * May panic if `tweak` is not the output of a SHA-256 hash. + * This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s + * [`CommonOpenChannelFields::channel_type`]. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKPublicKey add_public_key_tweak(struct LDKPublicKey base_point, const uint8_t (*tweak)[32]); +void CommonAcceptChannelFields_set_channel_type(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * Frees any resources used by the RevocationBasepoint, if is_owned is set and inner is non-NULL. + * Constructs a new CommonAcceptChannelFields given each field + * + * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void RevocationBasepoint_free(struct LDKRevocationBasepoint this_obj); - -struct LDKPublicKey RevocationBasepoint_get_a(const struct LDKRevocationBasepoint *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCommonAcceptChannelFields CommonAcceptChannelFields_new(struct LDKChannelId temporary_channel_id_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t minimum_depth_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_basepoint_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, struct LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg); -void RevocationBasepoint_set_a(struct LDKRevocationBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Creates a copy of the CommonAcceptChannelFields + */ +struct LDKCommonAcceptChannelFields CommonAcceptChannelFields_clone(const struct LDKCommonAcceptChannelFields *NONNULL_PTR orig); /** - * Constructs a new RevocationBasepoint given each field + * Generates a non-cryptographic 64-bit hash of the CommonAcceptChannelFields. */ -MUST_USE_RES struct LDKRevocationBasepoint RevocationBasepoint_new(struct LDKPublicKey a_arg); +uint64_t CommonAcceptChannelFields_hash(const struct LDKCommonAcceptChannelFields *NONNULL_PTR o); /** - * Checks if two RevocationBasepoints contain equal inner contents. + * Checks if two CommonAcceptChannelFieldss contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool RevocationBasepoint_eq(const struct LDKRevocationBasepoint *NONNULL_PTR a, const struct LDKRevocationBasepoint *NONNULL_PTR b); +bool CommonAcceptChannelFields_eq(const struct LDKCommonAcceptChannelFields *NONNULL_PTR a, const struct LDKCommonAcceptChannelFields *NONNULL_PTR b); /** - * Creates a copy of the RevocationBasepoint + * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. */ -struct LDKRevocationBasepoint RevocationBasepoint_clone(const struct LDKRevocationBasepoint *NONNULL_PTR orig); +void AcceptChannel_free(struct LDKAcceptChannel this_obj); /** - * Generates a non-cryptographic 64-bit hash of the RevocationBasepoint. + * Common fields of `accept_channel(2)`-like messages */ -uint64_t RevocationBasepoint_hash(const struct LDKRevocationBasepoint *NONNULL_PTR o); +struct LDKCommonAcceptChannelFields AcceptChannel_get_common_fields(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Get inner Public Key + * Common fields of `accept_channel(2)`-like messages */ -MUST_USE_RES struct LDKPublicKey RevocationBasepoint_to_public_key(const struct LDKRevocationBasepoint *NONNULL_PTR this_arg); +void AcceptChannel_set_common_fields(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKCommonAcceptChannelFields val); /** - * Serialize the RevocationBasepoint object into a byte array which can be read by RevocationBasepoint_read + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -struct LDKCVec_u8Z RevocationBasepoint_write(const struct LDKRevocationBasepoint *NONNULL_PTR obj); +uint64_t AcceptChannel_get_channel_reserve_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Read a RevocationBasepoint from a byte array, created by RevocationBasepoint_write + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -struct LDKCResult_RevocationBasepointDecodeErrorZ RevocationBasepoint_read(struct LDKu8slice ser); +void AcceptChannel_set_channel_reserve_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the RevocationKey, if is_owned is set and inner is non-NULL. + * Constructs a new AcceptChannel given each field */ -void RevocationKey_free(struct LDKRevocationKey this_obj); - -struct LDKPublicKey RevocationKey_get_a(const struct LDKRevocationKey *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKAcceptChannel AcceptChannel_new(struct LDKCommonAcceptChannelFields common_fields_arg, uint64_t channel_reserve_satoshis_arg); -void RevocationKey_set_a(struct LDKRevocationKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Creates a copy of the AcceptChannel + */ +struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); /** - * Constructs a new RevocationKey given each field + * Generates a non-cryptographic 64-bit hash of the AcceptChannel. */ -MUST_USE_RES struct LDKRevocationKey RevocationKey_new(struct LDKPublicKey a_arg); +uint64_t AcceptChannel_hash(const struct LDKAcceptChannel *NONNULL_PTR o); /** - * Checks if two RevocationKeys contain equal inner contents. + * Checks if two AcceptChannels contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool RevocationKey_eq(const struct LDKRevocationKey *NONNULL_PTR a, const struct LDKRevocationKey *NONNULL_PTR b); +bool AcceptChannel_eq(const struct LDKAcceptChannel *NONNULL_PTR a, const struct LDKAcceptChannel *NONNULL_PTR b); /** - * Creates a copy of the RevocationKey + * Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL. */ -struct LDKRevocationKey RevocationKey_clone(const struct LDKRevocationKey *NONNULL_PTR orig); +void AcceptChannelV2_free(struct LDKAcceptChannelV2 this_obj); /** - * Generates a non-cryptographic 64-bit hash of the RevocationKey. + * Common fields of `accept_channel(2)`-like messages */ -uint64_t RevocationKey_hash(const struct LDKRevocationKey *NONNULL_PTR o); +struct LDKCommonAcceptChannelFields AcceptChannelV2_get_common_fields(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Derives a per-commitment-transaction revocation public key from one party's per-commitment - * point and the other party's [`RevocationBasepoint`]. This is the public equivalent of - * [`chan_utils::derive_private_revocation_key`] - using only public keys to derive a public - * key instead of private keys. - * - * Note that this is infallible iff we trust that at least one of the two input keys are randomly - * generated (ie our own). - * - * [`chan_utils::derive_private_revocation_key`]: crate::ln::chan_utils::derive_private_revocation_key + * Common fields of `accept_channel(2)`-like messages */ -MUST_USE_RES struct LDKRevocationKey RevocationKey_from_basepoint(const struct LDKRevocationBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); +void AcceptChannelV2_set_common_fields(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKCommonAcceptChannelFields val); /** - * Get inner Public Key + * Part of the channel value contributed by the channel acceptor */ -MUST_USE_RES struct LDKPublicKey RevocationKey_to_public_key(const struct LDKRevocationKey *NONNULL_PTR this_arg); +uint64_t AcceptChannelV2_get_funding_satoshis(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Serialize the RevocationKey object into a byte array which can be read by RevocationKey_read + * Part of the channel value contributed by the channel acceptor */ -struct LDKCVec_u8Z RevocationKey_write(const struct LDKRevocationKey *NONNULL_PTR obj); +void AcceptChannelV2_set_funding_satoshis(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint64_t val); /** - * Read a RevocationKey from a byte array, created by RevocationKey_write + * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point */ -struct LDKCResult_RevocationKeyDecodeErrorZ RevocationKey_read(struct LDKu8slice ser); +struct LDKPublicKey AcceptChannelV2_get_second_per_commitment_point(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Creates a copy of the InboundHTLCStateDetails + * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point */ -enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_clone(const enum LDKInboundHTLCStateDetails *NONNULL_PTR orig); +void AcceptChannelV2_set_second_per_commitment_point(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Utility method to constructs a new AwaitingRemoteRevokeToAdd-variant InboundHTLCStateDetails + * Optionally, a requirement that only confirmed inputs can be added */ -enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_awaiting_remote_revoke_to_add(void); +enum LDKCOption_NoneZ AcceptChannelV2_get_require_confirmed_inputs(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Committed-variant InboundHTLCStateDetails + * Optionally, a requirement that only confirmed inputs can be added */ -enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_committed(void); +void AcceptChannelV2_set_require_confirmed_inputs(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); /** - * Utility method to constructs a new AwaitingRemoteRevokeToRemoveFulfill-variant InboundHTLCStateDetails + * Constructs a new AcceptChannelV2 given each field */ -enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_awaiting_remote_revoke_to_remove_fulfill(void); +MUST_USE_RES struct LDKAcceptChannelV2 AcceptChannelV2_new(struct LDKCommonAcceptChannelFields common_fields_arg, uint64_t funding_satoshis_arg, struct LDKPublicKey second_per_commitment_point_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); /** - * Utility method to constructs a new AwaitingRemoteRevokeToRemoveFail-variant InboundHTLCStateDetails + * Creates a copy of the AcceptChannelV2 */ -enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_awaiting_remote_revoke_to_remove_fail(void); +struct LDKAcceptChannelV2 AcceptChannelV2_clone(const struct LDKAcceptChannelV2 *NONNULL_PTR orig); /** - * Serialize the InboundHTLCStateDetails object into a byte array which can be read by InboundHTLCStateDetails_read + * Generates a non-cryptographic 64-bit hash of the AcceptChannelV2. */ -struct LDKCVec_u8Z InboundHTLCStateDetails_write(const enum LDKInboundHTLCStateDetails *NONNULL_PTR obj); +uint64_t AcceptChannelV2_hash(const struct LDKAcceptChannelV2 *NONNULL_PTR o); /** - * Read a InboundHTLCStateDetails from a byte array, created by InboundHTLCStateDetails_write + * Checks if two AcceptChannelV2s contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ InboundHTLCStateDetails_read(struct LDKu8slice ser); +bool AcceptChannelV2_eq(const struct LDKAcceptChannelV2 *NONNULL_PTR a, const struct LDKAcceptChannelV2 *NONNULL_PTR b); /** - * Frees any resources used by the InboundHTLCDetails, if is_owned is set and inner is non-NULL. + * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. */ -void InboundHTLCDetails_free(struct LDKInboundHTLCDetails this_obj); +void FundingCreated_free(struct LDKFundingCreated this_obj); /** - * The HTLC ID. - * The IDs are incremented by 1 starting from 0 for each offered HTLC. - * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced - * and not part of any commitment transaction. + * A temporary channel ID, until the funding is established */ -uint64_t InboundHTLCDetails_get_htlc_id(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); +struct LDKChannelId FundingCreated_get_temporary_channel_id(const struct LDKFundingCreated *NONNULL_PTR this_ptr); /** - * The HTLC ID. - * The IDs are incremented by 1 starting from 0 for each offered HTLC. - * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced - * and not part of any commitment transaction. + * A temporary channel ID, until the funding is established */ -void InboundHTLCDetails_set_htlc_id(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, uint64_t val); +void FundingCreated_set_temporary_channel_id(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The amount in msat. + * The funding transaction ID */ -uint64_t InboundHTLCDetails_get_amount_msat(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); +const uint8_t (*FundingCreated_get_funding_txid(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; /** - * The amount in msat. + * The funding transaction ID */ -void InboundHTLCDetails_set_amount_msat(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, uint64_t val); +void FundingCreated_set_funding_txid(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The block height at which this HTLC expires. + * The specific output index funding this channel */ -uint32_t InboundHTLCDetails_get_cltv_expiry(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); +uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated *NONNULL_PTR this_ptr); /** - * The block height at which this HTLC expires. + * The specific output index funding this channel */ -void InboundHTLCDetails_set_cltv_expiry(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, uint32_t val); +void FundingCreated_set_funding_output_index(struct LDKFundingCreated *NONNULL_PTR this_ptr, uint16_t val); /** - * The payment hash. + * The signature of the channel initiator (funder) on the initial commitment transaction */ -const uint8_t (*InboundHTLCDetails_get_payment_hash(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr))[32]; +struct LDKECDSASignature FundingCreated_get_signature(const struct LDKFundingCreated *NONNULL_PTR this_ptr); /** - * The payment hash. + * The signature of the channel initiator (funder) on the initial commitment transaction */ -void InboundHTLCDetails_set_payment_hash(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * The state of the HTLC in the state machine. - * - * Determines on which commitment transactions the HTLC is included and what message the HTLC is - * waiting for to advance to the next state. - * - * See [`InboundHTLCStateDetails`] for information on the specific states. - * - * LDK will always fill this field in, but when downgrading to prior versions of LDK, new - * states may result in `None` here. + * Constructs a new FundingCreated given each field */ -struct LDKCOption_InboundHTLCStateDetailsZ InboundHTLCDetails_get_state(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKChannelId temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKECDSASignature signature_arg); /** - * The state of the HTLC in the state machine. - * - * Determines on which commitment transactions the HTLC is included and what message the HTLC is - * waiting for to advance to the next state. - * - * See [`InboundHTLCStateDetails`] for information on the specific states. - * - * LDK will always fill this field in, but when downgrading to prior versions of LDK, new - * states may result in `None` here. + * Creates a copy of the FundingCreated */ -void InboundHTLCDetails_set_state(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_InboundHTLCStateDetailsZ val); +struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); /** - * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed - * from the local commitment transaction and added to the commitment transaction fee. - * For non-anchor channels, this takes into account the cost of the second-stage HTLC - * transactions as well. - * - * When the local commitment transaction is broadcasted as part of a unilateral closure, - * the value of this HTLC will therefore not be claimable but instead burned as a transaction - * fee. - * - * Note that dust limits are specific to each party. An HTLC can be dust for the local - * commitment transaction but not for the counterparty's commitment transaction and vice versa. + * Generates a non-cryptographic 64-bit hash of the FundingCreated. */ -bool InboundHTLCDetails_get_is_dust(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); +uint64_t FundingCreated_hash(const struct LDKFundingCreated *NONNULL_PTR o); /** - * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed - * from the local commitment transaction and added to the commitment transaction fee. - * For non-anchor channels, this takes into account the cost of the second-stage HTLC - * transactions as well. - * - * When the local commitment transaction is broadcasted as part of a unilateral closure, - * the value of this HTLC will therefore not be claimable but instead burned as a transaction - * fee. - * - * Note that dust limits are specific to each party. An HTLC can be dust for the local - * commitment transaction but not for the counterparty's commitment transaction and vice versa. + * Checks if two FundingCreateds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void InboundHTLCDetails_set_is_dust(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, bool val); +bool FundingCreated_eq(const struct LDKFundingCreated *NONNULL_PTR a, const struct LDKFundingCreated *NONNULL_PTR b); /** - * Constructs a new InboundHTLCDetails given each field + * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKInboundHTLCDetails InboundHTLCDetails_new(uint64_t htlc_id_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_InboundHTLCStateDetailsZ state_arg, bool is_dust_arg); +void FundingSigned_free(struct LDKFundingSigned this_obj); /** - * Creates a copy of the InboundHTLCDetails + * The channel ID */ -struct LDKInboundHTLCDetails InboundHTLCDetails_clone(const struct LDKInboundHTLCDetails *NONNULL_PTR orig); +struct LDKChannelId FundingSigned_get_channel_id(const struct LDKFundingSigned *NONNULL_PTR this_ptr); /** - * Serialize the InboundHTLCDetails object into a byte array which can be read by InboundHTLCDetails_read + * The channel ID */ -struct LDKCVec_u8Z InboundHTLCDetails_write(const struct LDKInboundHTLCDetails *NONNULL_PTR obj); +void FundingSigned_set_channel_id(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Read a InboundHTLCDetails from a byte array, created by InboundHTLCDetails_write + * The signature of the channel acceptor (fundee) on the initial commitment transaction */ -struct LDKCResult_InboundHTLCDetailsDecodeErrorZ InboundHTLCDetails_read(struct LDKu8slice ser); +struct LDKECDSASignature FundingSigned_get_signature(const struct LDKFundingSigned *NONNULL_PTR this_ptr); /** - * Creates a copy of the OutboundHTLCStateDetails + * The signature of the channel acceptor (fundee) on the initial commitment transaction */ -enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_clone(const enum LDKOutboundHTLCStateDetails *NONNULL_PTR orig); +void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * Utility method to constructs a new AwaitingRemoteRevokeToAdd-variant OutboundHTLCStateDetails + * Constructs a new FundingSigned given each field */ -enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_awaiting_remote_revoke_to_add(void); +MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKChannelId channel_id_arg, struct LDKECDSASignature signature_arg); /** - * Utility method to constructs a new Committed-variant OutboundHTLCStateDetails + * Creates a copy of the FundingSigned */ -enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_committed(void); +struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); /** - * Utility method to constructs a new AwaitingRemoteRevokeToRemoveSuccess-variant OutboundHTLCStateDetails + * Generates a non-cryptographic 64-bit hash of the FundingSigned. */ -enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_awaiting_remote_revoke_to_remove_success(void); +uint64_t FundingSigned_hash(const struct LDKFundingSigned *NONNULL_PTR o); /** - * Utility method to constructs a new AwaitingRemoteRevokeToRemoveFailure-variant OutboundHTLCStateDetails + * Checks if two FundingSigneds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_awaiting_remote_revoke_to_remove_failure(void); +bool FundingSigned_eq(const struct LDKFundingSigned *NONNULL_PTR a, const struct LDKFundingSigned *NONNULL_PTR b); /** - * Serialize the OutboundHTLCStateDetails object into a byte array which can be read by OutboundHTLCStateDetails_read + * Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z OutboundHTLCStateDetails_write(const enum LDKOutboundHTLCStateDetails *NONNULL_PTR obj); +void ChannelReady_free(struct LDKChannelReady this_obj); /** - * Read a OutboundHTLCStateDetails from a byte array, created by OutboundHTLCStateDetails_write + * The channel ID */ -struct LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ OutboundHTLCStateDetails_read(struct LDKu8slice ser); +struct LDKChannelId ChannelReady_get_channel_id(const struct LDKChannelReady *NONNULL_PTR this_ptr); /** - * Frees any resources used by the OutboundHTLCDetails, if is_owned is set and inner is non-NULL. + * The channel ID */ -void OutboundHTLCDetails_free(struct LDKOutboundHTLCDetails this_obj); +void ChannelReady_set_channel_id(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The HTLC ID. - * The IDs are incremented by 1 starting from 0 for each offered HTLC. - * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced - * and not part of any commitment transaction. + * The per-commitment point of the second commitment transaction + */ +struct LDKPublicKey ChannelReady_get_next_per_commitment_point(const struct LDKChannelReady *NONNULL_PTR this_ptr); + +/** + * The per-commitment point of the second commitment transaction + */ +void ChannelReady_set_next_per_commitment_point(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * If set, provides a `short_channel_id` alias for this channel. * - * Not present when we are awaiting a remote revocation and the HTLC is not added yet. + * The sender will accept payments to be forwarded over this SCID and forward them to this + * messages' recipient. */ -struct LDKCOption_u64Z OutboundHTLCDetails_get_htlc_id(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); +struct LDKCOption_u64Z ChannelReady_get_short_channel_id_alias(const struct LDKChannelReady *NONNULL_PTR this_ptr); /** - * The HTLC ID. - * The IDs are incremented by 1 starting from 0 for each offered HTLC. - * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced - * and not part of any commitment transaction. + * If set, provides a `short_channel_id` alias for this channel. * - * Not present when we are awaiting a remote revocation and the HTLC is not added yet. + * The sender will accept payments to be forwarded over this SCID and forward them to this + * messages' recipient. */ -void OutboundHTLCDetails_set_htlc_id(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void ChannelReady_set_short_channel_id_alias(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * The amount in msat. + * Constructs a new ChannelReady given each field */ -uint64_t OutboundHTLCDetails_get_amount_msat(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelReady ChannelReady_new(struct LDKChannelId channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg, struct LDKCOption_u64Z short_channel_id_alias_arg); /** - * The amount in msat. + * Creates a copy of the ChannelReady */ -void OutboundHTLCDetails_set_amount_msat(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, uint64_t val); +struct LDKChannelReady ChannelReady_clone(const struct LDKChannelReady *NONNULL_PTR orig); /** - * The block height at which this HTLC expires. + * Generates a non-cryptographic 64-bit hash of the ChannelReady. */ -uint32_t OutboundHTLCDetails_get_cltv_expiry(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); +uint64_t ChannelReady_hash(const struct LDKChannelReady *NONNULL_PTR o); /** - * The block height at which this HTLC expires. + * Checks if two ChannelReadys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void OutboundHTLCDetails_set_cltv_expiry(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, uint32_t val); +bool ChannelReady_eq(const struct LDKChannelReady *NONNULL_PTR a, const struct LDKChannelReady *NONNULL_PTR b); /** - * The payment hash. + * Frees any resources used by the Stfu, if is_owned is set and inner is non-NULL. */ -const uint8_t (*OutboundHTLCDetails_get_payment_hash(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr))[32]; +void Stfu_free(struct LDKStfu this_obj); /** - * The payment hash. + * The channel ID where quiescence is intended */ -void OutboundHTLCDetails_set_payment_hash(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKChannelId Stfu_get_channel_id(const struct LDKStfu *NONNULL_PTR this_ptr); /** - * The state of the HTLC in the state machine. - * - * Determines on which commitment transactions the HTLC is included and what message the HTLC is - * waiting for to advance to the next state. - * - * See [`OutboundHTLCStateDetails`] for information on the specific states. - * - * LDK will always fill this field in, but when downgrading to prior versions of LDK, new - * states may result in `None` here. + * The channel ID where quiescence is intended */ -struct LDKCOption_OutboundHTLCStateDetailsZ OutboundHTLCDetails_get_state(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); +void Stfu_set_channel_id(struct LDKStfu *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The state of the HTLC in the state machine. - * - * Determines on which commitment transactions the HTLC is included and what message the HTLC is - * waiting for to advance to the next state. - * - * See [`OutboundHTLCStateDetails`] for information on the specific states. - * - * LDK will always fill this field in, but when downgrading to prior versions of LDK, new - * states may result in `None` here. + * Initiator flag, 1 if initiating, 0 if replying to an stfu. */ -void OutboundHTLCDetails_set_state(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_OutboundHTLCStateDetailsZ val); +uint8_t Stfu_get_initiator(const struct LDKStfu *NONNULL_PTR this_ptr); /** - * The extra fee being skimmed off the top of this HTLC. + * Initiator flag, 1 if initiating, 0 if replying to an stfu. */ -struct LDKCOption_u64Z OutboundHTLCDetails_get_skimmed_fee_msat(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); +void Stfu_set_initiator(struct LDKStfu *NONNULL_PTR this_ptr, uint8_t val); /** - * The extra fee being skimmed off the top of this HTLC. + * Constructs a new Stfu given each field */ -void OutboundHTLCDetails_set_skimmed_fee_msat(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKStfu Stfu_new(struct LDKChannelId channel_id_arg, uint8_t initiator_arg); /** - * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed - * from the local commitment transaction and added to the commitment transaction fee. - * For non-anchor channels, this takes into account the cost of the second-stage HTLC - * transactions as well. - * - * When the local commitment transaction is broadcasted as part of a unilateral closure, - * the value of this HTLC will therefore not be claimable but instead burned as a transaction - * fee. - * - * Note that dust limits are specific to each party. An HTLC can be dust for the local - * commitment transaction but not for the counterparty's commitment transaction and vice versa. + * Creates a copy of the Stfu + */ +struct LDKStfu Stfu_clone(const struct LDKStfu *NONNULL_PTR orig); + +/** + * Checks if two Stfus contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool Stfu_eq(const struct LDKStfu *NONNULL_PTR a, const struct LDKStfu *NONNULL_PTR b); + +/** + * Frees any resources used by the SpliceInit, if is_owned is set and inner is non-NULL. */ -bool OutboundHTLCDetails_get_is_dust(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); +void SpliceInit_free(struct LDKSpliceInit this_obj); /** - * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed - * from the local commitment transaction and added to the commitment transaction fee. - * For non-anchor channels, this takes into account the cost of the second-stage HTLC - * transactions as well. - * - * When the local commitment transaction is broadcasted as part of a unilateral closure, - * the value of this HTLC will therefore not be claimable but instead burned as a transaction - * fee. - * - * Note that dust limits are specific to each party. An HTLC can be dust for the local - * commitment transaction but not for the counterparty's commitment transaction and vice versa. + * The channel ID where splicing is intended */ -void OutboundHTLCDetails_set_is_dust(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, bool val); +struct LDKChannelId SpliceInit_get_channel_id(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** - * Constructs a new OutboundHTLCDetails given each field + * The channel ID where splicing is intended */ -MUST_USE_RES struct LDKOutboundHTLCDetails OutboundHTLCDetails_new(struct LDKCOption_u64Z htlc_id_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_OutboundHTLCStateDetailsZ state_arg, struct LDKCOption_u64Z skimmed_fee_msat_arg, bool is_dust_arg); +void SpliceInit_set_channel_id(struct LDKSpliceInit *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Creates a copy of the OutboundHTLCDetails + * The amount the splice initiator is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). */ -struct LDKOutboundHTLCDetails OutboundHTLCDetails_clone(const struct LDKOutboundHTLCDetails *NONNULL_PTR orig); +int64_t SpliceInit_get_funding_contribution_satoshis(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** - * Serialize the OutboundHTLCDetails object into a byte array which can be read by OutboundHTLCDetails_read + * The amount the splice initiator is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). */ -struct LDKCVec_u8Z OutboundHTLCDetails_write(const struct LDKOutboundHTLCDetails *NONNULL_PTR obj); +void SpliceInit_set_funding_contribution_satoshis(struct LDKSpliceInit *NONNULL_PTR this_ptr, int64_t val); /** - * Read a OutboundHTLCDetails from a byte array, created by OutboundHTLCDetails_write + * The feerate for the new funding transaction, set by the splice initiator */ -struct LDKCResult_OutboundHTLCDetailsDecodeErrorZ OutboundHTLCDetails_read(struct LDKu8slice ser); +uint32_t SpliceInit_get_funding_feerate_perkw(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL. + * The feerate for the new funding transaction, set by the splice initiator */ -void CounterpartyForwardingInfo_free(struct LDKCounterpartyForwardingInfo this_obj); +void SpliceInit_set_funding_feerate_perkw(struct LDKSpliceInit *NONNULL_PTR this_ptr, uint32_t val); /** - * Base routing fee in millisatoshis. + * The locktime for the new funding transaction */ -uint32_t CounterpartyForwardingInfo_get_fee_base_msat(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +uint32_t SpliceInit_get_locktime(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** - * Base routing fee in millisatoshis. + * The locktime for the new funding transaction */ -void CounterpartyForwardingInfo_set_fee_base_msat(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); +void SpliceInit_set_locktime(struct LDKSpliceInit *NONNULL_PTR this_ptr, uint32_t val); /** - * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + * The key of the sender (splice initiator) controlling the new funding transaction */ -uint32_t CounterpartyForwardingInfo_get_fee_proportional_millionths(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +struct LDKPublicKey SpliceInit_get_funding_pubkey(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** - * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + * The key of the sender (splice initiator) controlling the new funding transaction */ -void CounterpartyForwardingInfo_set_fee_proportional_millionths(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); +void SpliceInit_set_funding_pubkey(struct LDKSpliceInit *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, - * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s - * `cltv_expiry_delta` for more details. + * If set, only confirmed inputs added (by the splice acceptor) will be accepted */ -uint16_t CounterpartyForwardingInfo_get_cltv_expiry_delta(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +enum LDKCOption_NoneZ SpliceInit_get_require_confirmed_inputs(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** - * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, - * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s - * `cltv_expiry_delta` for more details. + * If set, only confirmed inputs added (by the splice acceptor) will be accepted */ -void CounterpartyForwardingInfo_set_cltv_expiry_delta(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint16_t val); +void SpliceInit_set_require_confirmed_inputs(struct LDKSpliceInit *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); /** - * Constructs a new CounterpartyForwardingInfo given each field + * Constructs a new SpliceInit given each field */ -MUST_USE_RES struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg); +MUST_USE_RES struct LDKSpliceInit SpliceInit_new(struct LDKChannelId channel_id_arg, int64_t funding_contribution_satoshis_arg, uint32_t funding_feerate_perkw_arg, uint32_t locktime_arg, struct LDKPublicKey funding_pubkey_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); /** - * Creates a copy of the CounterpartyForwardingInfo + * Creates a copy of the SpliceInit */ -struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_clone(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR orig); +struct LDKSpliceInit SpliceInit_clone(const struct LDKSpliceInit *NONNULL_PTR orig); /** - * Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read + * Checks if two SpliceInits contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCVec_u8Z CounterpartyForwardingInfo_write(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR obj); +bool SpliceInit_eq(const struct LDKSpliceInit *NONNULL_PTR a, const struct LDKSpliceInit *NONNULL_PTR b); /** - * Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write + * Frees any resources used by the SpliceAck, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CounterpartyForwardingInfo_read(struct LDKu8slice ser); +void SpliceAck_free(struct LDKSpliceAck this_obj); /** - * Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL. + * The channel ID where splicing is intended */ -void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); +struct LDKChannelId SpliceAck_get_channel_id(const struct LDKSpliceAck *NONNULL_PTR this_ptr); /** - * The node_id of our counterparty + * The channel ID where splicing is intended */ -struct LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +void SpliceAck_set_channel_id(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The node_id of our counterparty + * The amount the splice acceptor is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). */ -void ChannelCounterparty_set_node_id(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKPublicKey val); +int64_t SpliceAck_get_funding_contribution_satoshis(const struct LDKSpliceAck *NONNULL_PTR this_ptr); /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. + * The amount the splice acceptor is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). */ -struct LDKInitFeatures ChannelCounterparty_get_features(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +void SpliceAck_set_funding_contribution_satoshis(struct LDKSpliceAck *NONNULL_PTR this_ptr, int64_t val); /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. + * The key of the sender (splice acceptor) controlling the new funding transaction */ -void ChannelCounterparty_set_features(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +struct LDKPublicKey SpliceAck_get_funding_pubkey(const struct LDKSpliceAck *NONNULL_PTR this_ptr); /** - * The value, in satoshis, that must always be held in the channel for our counterparty. This - * value ensures that if our counterparty broadcasts a revoked state, we can punish them by - * claiming at least this value on chain. - * - * This value is not included in [`inbound_capacity_msat`] as it can never be spent. - * - * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + * The key of the sender (splice acceptor) controlling the new funding transaction */ -uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +void SpliceAck_set_funding_pubkey(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The value, in satoshis, that must always be held in the channel for our counterparty. This - * value ensures that if our counterparty broadcasts a revoked state, we can punish them by - * claiming at least this value on chain. - * - * This value is not included in [`inbound_capacity_msat`] as it can never be spent. - * - * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + * If set, only confirmed inputs added (by the splice initiator) will be accepted */ -void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val); +enum LDKCOption_NoneZ SpliceAck_get_require_confirmed_inputs(const struct LDKSpliceAck *NONNULL_PTR this_ptr); /** - * Information on the fees and requirements that the counterparty requires when forwarding - * payments to us through this channel. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * If set, only confirmed inputs added (by the splice initiator) will be accepted */ -struct LDKCounterpartyForwardingInfo ChannelCounterparty_get_forwarding_info(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +void SpliceAck_set_require_confirmed_inputs(struct LDKSpliceAck *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); /** - * Information on the fees and requirements that the counterparty requires when forwarding - * payments to us through this channel. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new SpliceAck given each field */ -void ChannelCounterparty_set_forwarding_info(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCounterpartyForwardingInfo val); +MUST_USE_RES struct LDKSpliceAck SpliceAck_new(struct LDKChannelId channel_id_arg, int64_t funding_contribution_satoshis_arg, struct LDKPublicKey funding_pubkey_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); /** - * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field - * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message - * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. + * Creates a copy of the SpliceAck */ -struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_minimum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +struct LDKSpliceAck SpliceAck_clone(const struct LDKSpliceAck *NONNULL_PTR orig); /** - * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field - * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message - * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. + * Checks if two SpliceAcks contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelCounterparty_set_outbound_htlc_minimum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +bool SpliceAck_eq(const struct LDKSpliceAck *NONNULL_PTR a, const struct LDKSpliceAck *NONNULL_PTR b); /** - * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + * Frees any resources used by the SpliceLocked, if is_owned is set and inner is non-NULL. */ -struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_maximum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +void SpliceLocked_free(struct LDKSpliceLocked this_obj); /** - * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + * The channel ID */ -void ChannelCounterparty_set_outbound_htlc_maximum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKChannelId SpliceLocked_get_channel_id(const struct LDKSpliceLocked *NONNULL_PTR this_ptr); /** - * Constructs a new ChannelCounterparty given each field - * - * Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * The channel ID */ -MUST_USE_RES struct LDKChannelCounterparty ChannelCounterparty_new(struct LDKPublicKey node_id_arg, struct LDKInitFeatures features_arg, uint64_t unspendable_punishment_reserve_arg, struct LDKCounterpartyForwardingInfo forwarding_info_arg, struct LDKCOption_u64Z outbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z outbound_htlc_maximum_msat_arg); +void SpliceLocked_set_channel_id(struct LDKSpliceLocked *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Creates a copy of the ChannelCounterparty + * The ID of the new funding transaction that has been locked */ -struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); +const uint8_t (*SpliceLocked_get_splice_txid(const struct LDKSpliceLocked *NONNULL_PTR this_ptr))[32]; /** - * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read + * The ID of the new funding transaction that has been locked */ -struct LDKCVec_u8Z ChannelCounterparty_write(const struct LDKChannelCounterparty *NONNULL_PTR obj); +void SpliceLocked_set_splice_txid(struct LDKSpliceLocked *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write + * Constructs a new SpliceLocked given each field */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ ChannelCounterparty_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKSpliceLocked SpliceLocked_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes splice_txid_arg); /** - * Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. + * Creates a copy of the SpliceLocked */ -void ChannelDetails_free(struct LDKChannelDetails this_obj); +struct LDKSpliceLocked SpliceLocked_clone(const struct LDKSpliceLocked *NONNULL_PTR orig); /** - * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, - * thereafter this is the txid of the funding transaction xor the funding transaction output). - * Note that this means this value is *not* persistent - it can change once during the - * lifetime of the channel. + * Checks if two SpliceLockeds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKChannelId ChannelDetails_get_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +bool SpliceLocked_eq(const struct LDKSpliceLocked *NONNULL_PTR a, const struct LDKSpliceLocked *NONNULL_PTR b); /** - * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, - * thereafter this is the txid of the funding transaction xor the funding transaction output). - * Note that this means this value is *not* persistent - it can change once during the - * lifetime of the channel. + * Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL. */ -void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelId val); +void TxAddInput_free(struct LDKTxAddInput this_obj); /** - * Parameters which apply to our counterparty. See individual fields for more information. + * The channel ID */ -struct LDKChannelCounterparty ChannelDetails_get_counterparty(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKChannelId TxAddInput_get_channel_id(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * Parameters which apply to our counterparty. See individual fields for more information. + * The channel ID */ -void ChannelDetails_set_counterparty(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelCounterparty val); +void TxAddInput_set_channel_id(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The Channel's funding transaction output, if we've negotiated the funding transaction with - * our counterparty already. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * A randomly chosen unique identifier for this input, which is even for initiators and odd for + * non-initiators. */ -struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint64_t TxAddInput_get_serial_id(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * The Channel's funding transaction output, if we've negotiated the funding transaction with - * our counterparty already. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * A randomly chosen unique identifier for this input, which is even for initiators and odd for + * non-initiators. */ -void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void TxAddInput_set_serial_id(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint64_t val); /** - * The features which this channel operates with. See individual features for more info. - * - * `None` until negotiation completes and the channel type is finalized. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialized transaction that contains the output this input spends to verify that it is non + * malleable. */ -struct LDKChannelTypeFeatures ChannelDetails_get_channel_type(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKTransactionU16LenLimited TxAddInput_get_prevtx(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * The features which this channel operates with. See individual features for more info. - * - * `None` until negotiation completes and the channel type is finalized. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialized transaction that contains the output this input spends to verify that it is non + * malleable. */ -void ChannelDetails_set_channel_type(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +void TxAddInput_set_prevtx(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKTransactionU16LenLimited val); /** - * The position of the funding transaction in the chain. None if the funding transaction has - * not yet been confirmed and the channel fully opened. - * - * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound - * payments instead of this. See [`get_inbound_payment_scid`]. - * - * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may - * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. - * - * [`inbound_scid_alias`]: Self::inbound_scid_alias - * [`outbound_scid_alias`]: Self::outbound_scid_alias - * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid - * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid - * [`confirmations_required`]: Self::confirmations_required + * The index of the output being spent */ -struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint32_t TxAddInput_get_prevtx_out(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * The position of the funding transaction in the chain. None if the funding transaction has - * not yet been confirmed and the channel fully opened. - * - * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound - * payments instead of this. See [`get_inbound_payment_scid`]. - * - * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may - * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. - * - * [`inbound_scid_alias`]: Self::inbound_scid_alias - * [`outbound_scid_alias`]: Self::outbound_scid_alias - * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid - * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid - * [`confirmations_required`]: Self::confirmations_required + * The index of the output being spent */ -void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void TxAddInput_set_prevtx_out(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint32_t val); /** - * An optional [`short_channel_id`] alias for this channel, randomly generated by us and - * usable in place of [`short_channel_id`] to reference the channel in outbound routes when - * the channel has not yet been confirmed (as long as [`confirmations_required`] is - * `Some(0)`). - * - * This will be `None` as long as the channel is not available for routing outbound payments. - * - * [`short_channel_id`]: Self::short_channel_id - * [`confirmations_required`]: Self::confirmations_required + * The sequence number of this input */ -struct LDKCOption_u64Z ChannelDetails_get_outbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint32_t TxAddInput_get_sequence(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * An optional [`short_channel_id`] alias for this channel, randomly generated by us and - * usable in place of [`short_channel_id`] to reference the channel in outbound routes when - * the channel has not yet been confirmed (as long as [`confirmations_required`] is - * `Some(0)`). - * - * This will be `None` as long as the channel is not available for routing outbound payments. - * - * [`short_channel_id`]: Self::short_channel_id - * [`confirmations_required`]: Self::confirmations_required + * The sequence number of this input */ -void ChannelDetails_set_outbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void TxAddInput_set_sequence(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint32_t val); /** - * An optional [`short_channel_id`] alias for this channel, randomly generated by our - * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our - * counterparty will recognize the alias provided here in place of the [`short_channel_id`] - * when they see a payment to be routed to us. - * - * Our counterparty may choose to rotate this value at any time, though will always recognize - * previous values for inbound payment forwarding. - * - * [`short_channel_id`]: Self::short_channel_id + * The ID of the previous funding transaction, when it is being added as an input during splicing */ -struct LDKCOption_u64Z ChannelDetails_get_inbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKCOption_ThirtyTwoBytesZ TxAddInput_get_shared_input_txid(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * An optional [`short_channel_id`] alias for this channel, randomly generated by our - * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our - * counterparty will recognize the alias provided here in place of the [`short_channel_id`] - * when they see a payment to be routed to us. - * - * Our counterparty may choose to rotate this value at any time, though will always recognize - * previous values for inbound payment forwarding. - * - * [`short_channel_id`]: Self::short_channel_id + * The ID of the previous funding transaction, when it is being added as an input during splicing */ -void ChannelDetails_set_inbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void TxAddInput_set_shared_input_txid(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); /** - * The value, in satoshis, of this channel as appears in the funding output + * Constructs a new TxAddInput given each field */ -uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxAddInput TxAddInput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg, struct LDKTransactionU16LenLimited prevtx_arg, uint32_t prevtx_out_arg, uint32_t sequence_arg, struct LDKCOption_ThirtyTwoBytesZ shared_input_txid_arg); /** - * The value, in satoshis, of this channel as appears in the funding output + * Creates a copy of the TxAddInput */ -void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +struct LDKTxAddInput TxAddInput_clone(const struct LDKTxAddInput *NONNULL_PTR orig); /** - * The value, in satoshis, that must always be held in the channel for us. This value ensures - * that if we broadcast a revoked state, our counterparty can punish us by claiming at least - * this value on chain. - * - * This value is not included in [`outbound_capacity_msat`] as it can never be spent. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat + * Generates a non-cryptographic 64-bit hash of the TxAddInput. */ -struct LDKCOption_u64Z ChannelDetails_get_unspendable_punishment_reserve(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint64_t TxAddInput_hash(const struct LDKTxAddInput *NONNULL_PTR o); /** - * The value, in satoshis, that must always be held in the channel for us. This value ensures - * that if we broadcast a revoked state, our counterparty can punish us by claiming at least - * this value on chain. - * - * This value is not included in [`outbound_capacity_msat`] as it can never be spent. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat + * Checks if two TxAddInputs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelDetails_set_unspendable_punishment_reserve(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +bool TxAddInput_eq(const struct LDKTxAddInput *NONNULL_PTR a, const struct LDKTxAddInput *NONNULL_PTR b); /** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for an inbound channel. This may be zero for objects - * serialized with LDK versions prior to 0.0.113. - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL. */ -struct LDKU128 ChannelDetails_get_user_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxAddOutput_free(struct LDKTxAddOutput this_obj); /** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for an inbound channel. This may be zero for objects - * serialized with LDK versions prior to 0.0.113. - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * The channel ID */ -void ChannelDetails_set_user_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKU128 val); +struct LDKChannelId TxAddOutput_get_channel_id(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); /** - * The currently negotiated fee rate denominated in satoshi per 1000 weight units, - * which is applied to commitment and HTLC transactions. - * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. + * The channel ID */ -struct LDKCOption_u32Z ChannelDetails_get_feerate_sat_per_1000_weight(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxAddOutput_set_channel_id(struct LDKTxAddOutput *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The currently negotiated fee rate denominated in satoshi per 1000 weight units, - * which is applied to commitment and HTLC transactions. - * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. + * A randomly chosen unique identifier for this output, which is even for initiators and odd for + * non-initiators. */ -void ChannelDetails_set_feerate_sat_per_1000_weight(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +uint64_t TxAddOutput_get_serial_id(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); /** - * The available outbound capacity for sending HTLCs to the remote peer. This does not include - * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new outbound HTLCs). This further does not include any pending - * outgoing HTLCs which are awaiting some other resolution to be sent. - * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we - * should be able to spend nearly this amount. + * A randomly chosen unique identifier for this output, which is even for initiators and odd for + * non-initiators. */ -uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxAddOutput_set_serial_id(struct LDKTxAddOutput *NONNULL_PTR this_ptr, uint64_t val); /** - * The available outbound capacity for sending HTLCs to the remote peer. This does not include - * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new outbound HTLCs). This further does not include any pending - * outgoing HTLCs which are awaiting some other resolution to be sent. - * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we - * should be able to spend nearly this amount. + * The satoshi value of the output */ -void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +uint64_t TxAddOutput_get_sats(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); /** - * The available outbound capacity for sending a single HTLC to the remote peer. This is - * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by - * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us - * to use a limit as close as possible to the HTLC limit we can currently send. - * - * See also [`ChannelDetails::next_outbound_htlc_minimum_msat`] and - * [`ChannelDetails::outbound_capacity_msat`]. + * The satoshi value of the output */ -uint64_t ChannelDetails_get_next_outbound_htlc_limit_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxAddOutput_set_sats(struct LDKTxAddOutput *NONNULL_PTR this_ptr, uint64_t val); /** - * The available outbound capacity for sending a single HTLC to the remote peer. This is - * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by - * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us - * to use a limit as close as possible to the HTLC limit we can currently send. - * - * See also [`ChannelDetails::next_outbound_htlc_minimum_msat`] and - * [`ChannelDetails::outbound_capacity_msat`]. + * The scriptPubKey for the output */ -void ChannelDetails_set_next_outbound_htlc_limit_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z TxAddOutput_get_script(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); /** - * The minimum value for sending a single HTLC to the remote peer. This is the equivalent of - * [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than - * an upper-bound. This is intended for use when routing, allowing us to ensure we pick a - * route which is valid. + * The scriptPubKey for the output */ -uint64_t ChannelDetails_get_next_outbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxAddOutput_set_script(struct LDKTxAddOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * The minimum value for sending a single HTLC to the remote peer. This is the equivalent of - * [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than - * an upper-bound. This is intended for use when routing, allowing us to ensure we pick a - * route which is valid. + * Constructs a new TxAddOutput given each field */ -void ChannelDetails_set_next_outbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKTxAddOutput TxAddOutput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg, uint64_t sats_arg, struct LDKCVec_u8Z script_arg); /** - * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new inbound HTLCs). - * Note that there are some corner cases not fully handled here, so the actual available - * inbound capacity may be slightly higher than this. - * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. - * However, our counterparty should be able to spend nearly this amount. + * Creates a copy of the TxAddOutput */ -uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKTxAddOutput TxAddOutput_clone(const struct LDKTxAddOutput *NONNULL_PTR orig); /** - * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new inbound HTLCs). - * Note that there are some corner cases not fully handled here, so the actual available - * inbound capacity may be slightly higher than this. - * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. - * However, our counterparty should be able to spend nearly this amount. + * Generates a non-cryptographic 64-bit hash of the TxAddOutput. */ -void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +uint64_t TxAddOutput_hash(const struct LDKTxAddOutput *NONNULL_PTR o); /** - * The number of required confirmations on the funding transaction before the funding will be - * considered \"locked\". This number is selected by the channel fundee (i.e. us if - * [`is_outbound`] is *not* set), and can be selected for inbound channels with - * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with - * [`ChannelHandshakeLimits::max_minimum_depth`]. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`is_outbound`]: ChannelDetails::is_outbound - * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth - * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + * Checks if two TxAddOutputs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCOption_u32Z ChannelDetails_get_confirmations_required(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +bool TxAddOutput_eq(const struct LDKTxAddOutput *NONNULL_PTR a, const struct LDKTxAddOutput *NONNULL_PTR b); /** - * The number of required confirmations on the funding transaction before the funding will be - * considered \"locked\". This number is selected by the channel fundee (i.e. us if - * [`is_outbound`] is *not* set), and can be selected for inbound channels with - * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with - * [`ChannelHandshakeLimits::max_minimum_depth`]. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`is_outbound`]: ChannelDetails::is_outbound - * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth - * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + * Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL. */ -void ChannelDetails_set_confirmations_required(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +void TxRemoveInput_free(struct LDKTxRemoveInput this_obj); /** - * The current number of confirmations on the funding transaction. - * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. + * The channel ID */ -struct LDKCOption_u32Z ChannelDetails_get_confirmations(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKChannelId TxRemoveInput_get_channel_id(const struct LDKTxRemoveInput *NONNULL_PTR this_ptr); /** - * The current number of confirmations on the funding transaction. - * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. + * The channel ID */ -void ChannelDetails_set_confirmations(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +void TxRemoveInput_set_channel_id(struct LDKTxRemoveInput *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The number of blocks (after our commitment transaction confirms) that we will need to wait - * until we can claim our funds after we force-close the channel. During this time our - * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty - * force-closes the channel and broadcasts a commitment transaction we do not have to wait any - * time to claim our non-HTLC-encumbered funds. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. + * The serial ID of the input to be removed */ -struct LDKCOption_u16Z ChannelDetails_get_force_close_spend_delay(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint64_t TxRemoveInput_get_serial_id(const struct LDKTxRemoveInput *NONNULL_PTR this_ptr); /** - * The number of blocks (after our commitment transaction confirms) that we will need to wait - * until we can claim our funds after we force-close the channel. During this time our - * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty - * force-closes the channel and broadcasts a commitment transaction we do not have to wait any - * time to claim our non-HTLC-encumbered funds. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. + * The serial ID of the input to be removed */ -void ChannelDetails_set_force_close_spend_delay(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); +void TxRemoveInput_set_serial_id(struct LDKTxRemoveInput *NONNULL_PTR this_ptr, uint64_t val); /** - * True if the channel was initiated (and thus funded) by us. + * Constructs a new TxRemoveInput given each field */ -bool ChannelDetails_get_is_outbound(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxRemoveInput TxRemoveInput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg); /** - * True if the channel was initiated (and thus funded) by us. + * Creates a copy of the TxRemoveInput */ -void ChannelDetails_set_is_outbound(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +struct LDKTxRemoveInput TxRemoveInput_clone(const struct LDKTxRemoveInput *NONNULL_PTR orig); /** - * True if the channel is confirmed, channel_ready messages have been exchanged, and the - * channel is not currently being shut down. `channel_ready` message exchange implies the - * required confirmation count has been reached (and we were connected to the peer at some - * point after the funding transaction received enough confirmations). The required - * confirmation count is provided in [`confirmations_required`]. - * - * [`confirmations_required`]: ChannelDetails::confirmations_required + * Generates a non-cryptographic 64-bit hash of the TxRemoveInput. */ -bool ChannelDetails_get_is_channel_ready(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint64_t TxRemoveInput_hash(const struct LDKTxRemoveInput *NONNULL_PTR o); /** - * True if the channel is confirmed, channel_ready messages have been exchanged, and the - * channel is not currently being shut down. `channel_ready` message exchange implies the - * required confirmation count has been reached (and we were connected to the peer at some - * point after the funding transaction received enough confirmations). The required - * confirmation count is provided in [`confirmations_required`]. - * - * [`confirmations_required`]: ChannelDetails::confirmations_required + * Checks if two TxRemoveInputs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelDetails_set_is_channel_ready(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +bool TxRemoveInput_eq(const struct LDKTxRemoveInput *NONNULL_PTR a, const struct LDKTxRemoveInput *NONNULL_PTR b); /** - * The stage of the channel's shutdown. - * `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. - * - * Returns a copy of the field. + * Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL. */ -struct LDKCOption_ChannelShutdownStateZ ChannelDetails_get_channel_shutdown_state(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxRemoveOutput_free(struct LDKTxRemoveOutput this_obj); /** - * The stage of the channel's shutdown. - * `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. + * The channel ID */ -void ChannelDetails_set_channel_shutdown_state(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_ChannelShutdownStateZ val); +struct LDKChannelId TxRemoveOutput_get_channel_id(const struct LDKTxRemoveOutput *NONNULL_PTR this_ptr); /** - * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) - * the peer is connected, and (c) the channel is not currently negotiating a shutdown. - * - * This is a strict superset of `is_channel_ready`. + * The channel ID */ -bool ChannelDetails_get_is_usable(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxRemoveOutput_set_channel_id(struct LDKTxRemoveOutput *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) - * the peer is connected, and (c) the channel is not currently negotiating a shutdown. - * - * This is a strict superset of `is_channel_ready`. + * The serial ID of the output to be removed */ -void ChannelDetails_set_is_usable(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +uint64_t TxRemoveOutput_get_serial_id(const struct LDKTxRemoveOutput *NONNULL_PTR this_ptr); /** - * True if this channel is (or will be) publicly-announced. + * The serial ID of the output to be removed */ -bool ChannelDetails_get_is_announced(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxRemoveOutput_set_serial_id(struct LDKTxRemoveOutput *NONNULL_PTR this_ptr, uint64_t val); /** - * True if this channel is (or will be) publicly-announced. + * Constructs a new TxRemoveOutput given each field */ -void ChannelDetails_set_is_announced(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKTxRemoveOutput TxRemoveOutput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg); /** - * The smallest value HTLC (in msat) we will accept, for this channel. This field - * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 + * Creates a copy of the TxRemoveOutput */ -struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKTxRemoveOutput TxRemoveOutput_clone(const struct LDKTxRemoveOutput *NONNULL_PTR orig); /** - * The smallest value HTLC (in msat) we will accept, for this channel. This field - * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 + * Generates a non-cryptographic 64-bit hash of the TxRemoveOutput. */ -void ChannelDetails_set_inbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +uint64_t TxRemoveOutput_hash(const struct LDKTxRemoveOutput *NONNULL_PTR o); /** - * The largest value HTLC (in msat) we currently will accept, for this channel. + * Checks if two TxRemoveOutputs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_maximum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +bool TxRemoveOutput_eq(const struct LDKTxRemoveOutput *NONNULL_PTR a, const struct LDKTxRemoveOutput *NONNULL_PTR b); /** - * The largest value HTLC (in msat) we currently will accept, for this channel. + * Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL. */ -void ChannelDetails_set_inbound_htlc_maximum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void TxComplete_free(struct LDKTxComplete this_obj); /** - * Set of configurable parameters that affect channel operation. - * - * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The channel ID */ -struct LDKChannelConfig ChannelDetails_get_config(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKChannelId TxComplete_get_channel_id(const struct LDKTxComplete *NONNULL_PTR this_ptr); /** - * Set of configurable parameters that affect channel operation. - * - * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The channel ID */ -void ChannelDetails_set_config(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelConfig val); +void TxComplete_set_channel_id(struct LDKTxComplete *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Pending inbound HTLCs. - * - * This field is empty for objects serialized with LDK versions prior to 0.0.122. + * Constructs a new TxComplete given each field */ -struct LDKCVec_InboundHTLCDetailsZ ChannelDetails_get_pending_inbound_htlcs(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxComplete TxComplete_new(struct LDKChannelId channel_id_arg); /** - * Pending inbound HTLCs. - * - * This field is empty for objects serialized with LDK versions prior to 0.0.122. + * Creates a copy of the TxComplete */ -void ChannelDetails_set_pending_inbound_htlcs(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCVec_InboundHTLCDetailsZ val); +struct LDKTxComplete TxComplete_clone(const struct LDKTxComplete *NONNULL_PTR orig); /** - * Pending outbound HTLCs. - * - * This field is empty for objects serialized with LDK versions prior to 0.0.122. + * Generates a non-cryptographic 64-bit hash of the TxComplete. */ -struct LDKCVec_OutboundHTLCDetailsZ ChannelDetails_get_pending_outbound_htlcs(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint64_t TxComplete_hash(const struct LDKTxComplete *NONNULL_PTR o); /** - * Pending outbound HTLCs. - * - * This field is empty for objects serialized with LDK versions prior to 0.0.122. + * Checks if two TxCompletes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelDetails_set_pending_outbound_htlcs(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCVec_OutboundHTLCDetailsZ val); +bool TxComplete_eq(const struct LDKTxComplete *NONNULL_PTR a, const struct LDKTxComplete *NONNULL_PTR b); /** - * Constructs a new ChannelDetails given each field - * - * Note that funding_txo_arg (or a relevant inner pointer) may be NULL or all-0s to represent None - * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None - * Note that config_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKChannelId channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKChannelTypeFeatures channel_type_arg, struct LDKCOption_u64Z short_channel_id_arg, struct LDKCOption_u64Z outbound_scid_alias_arg, struct LDKCOption_u64Z inbound_scid_alias_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, struct LDKU128 user_channel_id_arg, struct LDKCOption_u32Z feerate_sat_per_1000_weight_arg, uint64_t outbound_capacity_msat_arg, uint64_t next_outbound_htlc_limit_msat_arg, uint64_t next_outbound_htlc_minimum_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u32Z confirmations_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_channel_ready_arg, struct LDKCOption_ChannelShutdownStateZ channel_shutdown_state_arg, bool is_usable_arg, bool is_announced_arg, struct LDKCOption_u64Z inbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z inbound_htlc_maximum_msat_arg, struct LDKChannelConfig config_arg, struct LDKCVec_InboundHTLCDetailsZ pending_inbound_htlcs_arg, struct LDKCVec_OutboundHTLCDetailsZ pending_outbound_htlcs_arg); +void TxSignatures_free(struct LDKTxSignatures this_obj); /** - * Creates a copy of the ChannelDetails + * The channel ID */ -struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); +struct LDKChannelId TxSignatures_get_channel_id(const struct LDKTxSignatures *NONNULL_PTR this_ptr); /** - * Gets the current SCID which should be used to identify this channel for inbound payments. - * This should be used for providing invoice hints or in any other context where our - * counterparty will forward a payment to us. - * - * This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the - * [`ChannelDetails::short_channel_id`]. See those for more information. + * The channel ID */ -MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_inbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); +void TxSignatures_set_channel_id(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Gets the current SCID which should be used to identify this channel for outbound payments. - * This should be used in [`Route`]s to describe the first hop or in other contexts where - * we're sending or forwarding a payment outbound over this channel. - * - * This is either the [`ChannelDetails::short_channel_id`], if set, or the - * [`ChannelDetails::outbound_scid_alias`]. See those for more information. - * - * [`Route`]: crate::routing::router::Route + * The TXID */ -MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_outbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); +const uint8_t (*TxSignatures_get_tx_hash(const struct LDKTxSignatures *NONNULL_PTR this_ptr))[32]; /** - * Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read + * The TXID */ -struct LDKCVec_u8Z ChannelDetails_write(const struct LDKChannelDetails *NONNULL_PTR obj); +void TxSignatures_set_tx_hash(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a ChannelDetails from a byte array, created by ChannelDetails_write + * The list of witnesses + * + * Returns a copy of the field. */ -struct LDKCResult_ChannelDetailsDecodeErrorZ ChannelDetails_read(struct LDKu8slice ser); +struct LDKCVec_WitnessZ TxSignatures_get_witnesses(const struct LDKTxSignatures *NONNULL_PTR this_ptr); /** - * Creates a copy of the ChannelShutdownState + * The list of witnesses */ -enum LDKChannelShutdownState ChannelShutdownState_clone(const enum LDKChannelShutdownState *NONNULL_PTR orig); +void TxSignatures_set_witnesses(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKCVec_WitnessZ val); /** - * Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState + * Optional signature for the shared input -- the previous funding outpoint -- signed by both peers */ -enum LDKChannelShutdownState ChannelShutdownState_not_shutting_down(void); +struct LDKCOption_ECDSASignatureZ TxSignatures_get_shared_input_signature(const struct LDKTxSignatures *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState + * Optional signature for the shared input -- the previous funding outpoint -- signed by both peers */ -enum LDKChannelShutdownState ChannelShutdownState_shutdown_initiated(void); +void TxSignatures_set_shared_input_signature(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKCOption_ECDSASignatureZ val); /** - * Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState + * Constructs a new TxSignatures given each field */ -enum LDKChannelShutdownState ChannelShutdownState_resolving_htlcs(void); +MUST_USE_RES struct LDKTxSignatures TxSignatures_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes tx_hash_arg, struct LDKCVec_WitnessZ witnesses_arg, struct LDKCOption_ECDSASignatureZ shared_input_signature_arg); /** - * Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState + * Creates a copy of the TxSignatures */ -enum LDKChannelShutdownState ChannelShutdownState_negotiating_closing_fee(void); +struct LDKTxSignatures TxSignatures_clone(const struct LDKTxSignatures *NONNULL_PTR orig); /** - * Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState + * Generates a non-cryptographic 64-bit hash of the TxSignatures. */ -enum LDKChannelShutdownState ChannelShutdownState_shutdown_complete(void); +uint64_t TxSignatures_hash(const struct LDKTxSignatures *NONNULL_PTR o); /** - * Checks if two ChannelShutdownStates contain equal inner contents. + * Checks if two TxSignaturess contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -bool ChannelShutdownState_eq(const enum LDKChannelShutdownState *NONNULL_PTR a, const enum LDKChannelShutdownState *NONNULL_PTR b); +bool TxSignatures_eq(const struct LDKTxSignatures *NONNULL_PTR a, const struct LDKTxSignatures *NONNULL_PTR b); /** - * Serialize the ChannelShutdownState object into a byte array which can be read by ChannelShutdownState_read + * Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z ChannelShutdownState_write(const enum LDKChannelShutdownState *NONNULL_PTR obj); +void TxInitRbf_free(struct LDKTxInitRbf this_obj); /** - * Read a ChannelShutdownState from a byte array, created by ChannelShutdownState_write + * The channel ID */ -struct LDKCResult_ChannelShutdownStateDecodeErrorZ ChannelShutdownState_read(struct LDKu8slice ser); +struct LDKChannelId TxInitRbf_get_channel_id(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ExpandedKey, if is_owned is set and inner is non-NULL. + * The channel ID */ -void ExpandedKey_free(struct LDKExpandedKey this_obj); +void TxInitRbf_set_channel_id(struct LDKTxInitRbf *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Generates a non-cryptographic 64-bit hash of the ExpandedKey. + * The locktime of the transaction */ -uint64_t ExpandedKey_hash(const struct LDKExpandedKey *NONNULL_PTR o); +uint32_t TxInitRbf_get_locktime(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); /** - * Creates a copy of the ExpandedKey + * The locktime of the transaction */ -struct LDKExpandedKey ExpandedKey_clone(const struct LDKExpandedKey *NONNULL_PTR orig); +void TxInitRbf_set_locktime(struct LDKTxInitRbf *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if two ExpandedKeys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The feerate of the transaction */ -bool ExpandedKey_eq(const struct LDKExpandedKey *NONNULL_PTR a, const struct LDKExpandedKey *NONNULL_PTR b); +uint32_t TxInitRbf_get_feerate_sat_per_1000_weight(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); /** - * Create a new [`ExpandedKey`] for generating an inbound payment hash and secret. - * - * It is recommended to cache this value and not regenerate it for each new inbound payment. + * The feerate of the transaction */ -MUST_USE_RES struct LDKExpandedKey ExpandedKey_new(struct LDKThirtyTwoBytes key_material); +void TxInitRbf_set_feerate_sat_per_1000_weight(struct LDKTxInitRbf *NONNULL_PTR this_ptr, uint32_t val); /** - * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no - * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without - * a `ChannelManager`. - * - * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key`]. It is recommended to - * cache this value and not regenerate it for each new inbound payment. - * - * `current_time` is a Unix timestamp representing the current time. - * - * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable - * on versions of LDK prior to 0.0.114. - * - * [phantom node payments]: crate::sign::PhantomKeysManager - * [`NodeSigner::get_inbound_payment_key`]: crate::sign::NodeSigner::get_inbound_payment_key + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ create(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, const struct LDKEntropySource *NONNULL_PTR entropy_source, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +struct LDKCOption_i64Z TxInitRbf_get_funding_output_contribution(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); /** - * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`], - * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments] - * without a `ChannelManager`. - * - * See [`create`] for information on the `keys` and `current_time` parameters. - * - * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable - * on versions of LDK prior to 0.0.114. - * - * [phantom node payments]: crate::sign::PhantomKeysManager + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -struct LDKCResult_ThirtyTwoBytesNoneZ create_from_hash(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, struct LDKThirtyTwoBytes payment_hash, uint32_t invoice_expiry_delta_secs, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +void TxInitRbf_set_funding_output_contribution(struct LDKTxInitRbf *NONNULL_PTR this_ptr, struct LDKCOption_i64Z val); /** - * Frees any resources used by the DecodeError + * Constructs a new TxInitRbf given each field */ -void DecodeError_free(struct LDKDecodeError this_ptr); +MUST_USE_RES struct LDKTxInitRbf TxInitRbf_new(struct LDKChannelId channel_id_arg, uint32_t locktime_arg, uint32_t feerate_sat_per_1000_weight_arg, struct LDKCOption_i64Z funding_output_contribution_arg); /** - * Creates a copy of the DecodeError + * Creates a copy of the TxInitRbf */ -struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); +struct LDKTxInitRbf TxInitRbf_clone(const struct LDKTxInitRbf *NONNULL_PTR orig); /** - * Utility method to constructs a new UnknownVersion-variant DecodeError + * Generates a non-cryptographic 64-bit hash of the TxInitRbf. */ -struct LDKDecodeError DecodeError_unknown_version(void); +uint64_t TxInitRbf_hash(const struct LDKTxInitRbf *NONNULL_PTR o); /** - * Utility method to constructs a new UnknownRequiredFeature-variant DecodeError + * Checks if two TxInitRbfs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKDecodeError DecodeError_unknown_required_feature(void); +bool TxInitRbf_eq(const struct LDKTxInitRbf *NONNULL_PTR a, const struct LDKTxInitRbf *NONNULL_PTR b); /** - * Utility method to constructs a new InvalidValue-variant DecodeError + * Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL. */ -struct LDKDecodeError DecodeError_invalid_value(void); +void TxAckRbf_free(struct LDKTxAckRbf this_obj); /** - * Utility method to constructs a new ShortRead-variant DecodeError + * The channel ID */ -struct LDKDecodeError DecodeError_short_read(void); +struct LDKChannelId TxAckRbf_get_channel_id(const struct LDKTxAckRbf *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new BadLengthDescriptor-variant DecodeError + * The channel ID */ -struct LDKDecodeError DecodeError_bad_length_descriptor(void); +void TxAckRbf_set_channel_id(struct LDKTxAckRbf *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Utility method to constructs a new Io-variant DecodeError + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -struct LDKDecodeError DecodeError_io(enum LDKIOError a); +struct LDKCOption_i64Z TxAckRbf_get_funding_output_contribution(const struct LDKTxAckRbf *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new UnsupportedCompression-variant DecodeError + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -struct LDKDecodeError DecodeError_unsupported_compression(void); +void TxAckRbf_set_funding_output_contribution(struct LDKTxAckRbf *NONNULL_PTR this_ptr, struct LDKCOption_i64Z val); /** - * Utility method to constructs a new DangerousValue-variant DecodeError + * Constructs a new TxAckRbf given each field */ -struct LDKDecodeError DecodeError_dangerous_value(void); +MUST_USE_RES struct LDKTxAckRbf TxAckRbf_new(struct LDKChannelId channel_id_arg, struct LDKCOption_i64Z funding_output_contribution_arg); /** - * Generates a non-cryptographic 64-bit hash of the DecodeError. + * Creates a copy of the TxAckRbf */ -uint64_t DecodeError_hash(const struct LDKDecodeError *NONNULL_PTR o); +struct LDKTxAckRbf TxAckRbf_clone(const struct LDKTxAckRbf *NONNULL_PTR orig); /** - * Checks if two DecodeErrors contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the TxAckRbf. + */ +uint64_t TxAckRbf_hash(const struct LDKTxAckRbf *NONNULL_PTR o); + +/** + * Checks if two TxAckRbfs contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -bool DecodeError_eq(const struct LDKDecodeError *NONNULL_PTR a, const struct LDKDecodeError *NONNULL_PTR b); +bool TxAckRbf_eq(const struct LDKTxAckRbf *NONNULL_PTR a, const struct LDKTxAckRbf *NONNULL_PTR b); /** - * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. + * Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL. */ -void Init_free(struct LDKInit this_obj); +void TxAbort_free(struct LDKTxAbort this_obj); /** - * The relevant features which the sender supports. + * The channel ID */ -struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ptr); +struct LDKChannelId TxAbort_get_channel_id(const struct LDKTxAbort *NONNULL_PTR this_ptr); /** - * The relevant features which the sender supports. + * The channel ID */ -void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +void TxAbort_set_channel_id(struct LDKTxAbort *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Indicates chains the sender is interested in. - * - * If there are no common chains, the connection will be closed. + * Message data * * Returns a copy of the field. */ -struct LDKCOption_CVec_ThirtyTwoBytesZZ Init_get_networks(const struct LDKInit *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z TxAbort_get_data(const struct LDKTxAbort *NONNULL_PTR this_ptr); /** - * Indicates chains the sender is interested in. - * - * If there are no common chains, the connection will be closed. + * Message data */ -void Init_set_networks(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_CVec_ThirtyTwoBytesZZ val); +void TxAbort_set_data(struct LDKTxAbort *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * The receipient's network address. - * - * This adds the option to report a remote IP address back to a connecting peer using the init - * message. A node can decide to use that information to discover a potential update to its - * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing - * the new address. + * Constructs a new TxAbort given each field */ -struct LDKCOption_SocketAddressZ Init_get_remote_network_address(const struct LDKInit *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxAbort TxAbort_new(struct LDKChannelId channel_id_arg, struct LDKCVec_u8Z data_arg); /** - * The receipient's network address. - * - * This adds the option to report a remote IP address back to a connecting peer using the init - * message. A node can decide to use that information to discover a potential update to its - * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing - * the new address. + * Creates a copy of the TxAbort */ -void Init_set_remote_network_address(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_SocketAddressZ val); +struct LDKTxAbort TxAbort_clone(const struct LDKTxAbort *NONNULL_PTR orig); /** - * Constructs a new Init given each field + * Generates a non-cryptographic 64-bit hash of the TxAbort. */ -MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg, struct LDKCOption_CVec_ThirtyTwoBytesZZ networks_arg, struct LDKCOption_SocketAddressZ remote_network_address_arg); +uint64_t TxAbort_hash(const struct LDKTxAbort *NONNULL_PTR o); /** - * Creates a copy of the Init + * Checks if two TxAborts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); +bool TxAbort_eq(const struct LDKTxAbort *NONNULL_PTR a, const struct LDKTxAbort *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the Init. + * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. */ -uint64_t Init_hash(const struct LDKInit *NONNULL_PTR o); +void Shutdown_free(struct LDKShutdown this_obj); /** - * Checks if two Inits contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The channel ID */ -bool Init_eq(const struct LDKInit *NONNULL_PTR a, const struct LDKInit *NONNULL_PTR b); +struct LDKChannelId Shutdown_get_channel_id(const struct LDKShutdown *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. + * The channel ID */ -void ErrorMessage_free(struct LDKErrorMessage this_obj); +void Shutdown_set_channel_id(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The channel ID involved in the error. + * The destination of this peer's funds on closing. * - * All-0s indicates a general error unrelated to a specific channel, after which all channels - * with the sending peer should be closed. + * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. */ -struct LDKChannelId ErrorMessage_get_channel_id(const struct LDKErrorMessage *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Shutdown_get_scriptpubkey(const struct LDKShutdown *NONNULL_PTR this_ptr); /** - * The channel ID involved in the error. + * The destination of this peer's funds on closing. * - * All-0s indicates a general error unrelated to a specific channel, after which all channels - * with the sending peer should be closed. + * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. */ -void ErrorMessage_set_channel_id(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKChannelId val); +void Shutdown_set_scriptpubkey(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * A possibly human-readable error description. - * - * The string should be sanitized before it is used (e.g., emitted to logs or printed to - * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * Constructs a new Shutdown given each field */ -struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKChannelId channel_id_arg, struct LDKCVec_u8Z scriptpubkey_arg); /** - * A possibly human-readable error description. - * - * The string should be sanitized before it is used (e.g., emitted to logs or printed to - * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * Creates a copy of the Shutdown */ -void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKStr val); +struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); /** - * Constructs a new ErrorMessage given each field + * Generates a non-cryptographic 64-bit hash of the Shutdown. */ -MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKChannelId channel_id_arg, struct LDKStr data_arg); +uint64_t Shutdown_hash(const struct LDKShutdown *NONNULL_PTR o); /** - * Creates a copy of the ErrorMessage + * Checks if two Shutdowns contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); +bool Shutdown_eq(const struct LDKShutdown *NONNULL_PTR a, const struct LDKShutdown *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the ErrorMessage. + * Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL. */ -uint64_t ErrorMessage_hash(const struct LDKErrorMessage *NONNULL_PTR o); +void ClosingSignedFeeRange_free(struct LDKClosingSignedFeeRange this_obj); /** - * Checks if two ErrorMessages contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -bool ErrorMessage_eq(const struct LDKErrorMessage *NONNULL_PTR a, const struct LDKErrorMessage *NONNULL_PTR b); +uint64_t ClosingSignedFeeRange_get_min_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); /** - * Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL. + * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -void WarningMessage_free(struct LDKWarningMessage this_obj); +void ClosingSignedFeeRange_set_min_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); /** - * The channel ID involved in the warning. - * - * All-0s indicates a warning unrelated to a specific channel. + * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -struct LDKChannelId WarningMessage_get_channel_id(const struct LDKWarningMessage *NONNULL_PTR this_ptr); +uint64_t ClosingSignedFeeRange_get_max_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); /** - * The channel ID involved in the warning. - * - * All-0s indicates a warning unrelated to a specific channel. + * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -void WarningMessage_set_channel_id(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKChannelId val); +void ClosingSignedFeeRange_set_max_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); /** - * A possibly human-readable warning description. - * - * The string should be sanitized before it is used (e.g. emitted to logs or printed to - * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * Constructs a new ClosingSignedFeeRange given each field + */ +MUST_USE_RES struct LDKClosingSignedFeeRange ClosingSignedFeeRange_new(uint64_t min_fee_satoshis_arg, uint64_t max_fee_satoshis_arg); + +/** + * Creates a copy of the ClosingSignedFeeRange + */ +struct LDKClosingSignedFeeRange ClosingSignedFeeRange_clone(const struct LDKClosingSignedFeeRange *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the ClosingSignedFeeRange. + */ +uint64_t ClosingSignedFeeRange_hash(const struct LDKClosingSignedFeeRange *NONNULL_PTR o); + +/** + * Checks if two ClosingSignedFeeRanges contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKStr WarningMessage_get_data(const struct LDKWarningMessage *NONNULL_PTR this_ptr); +bool ClosingSignedFeeRange_eq(const struct LDKClosingSignedFeeRange *NONNULL_PTR a, const struct LDKClosingSignedFeeRange *NONNULL_PTR b); /** - * A possibly human-readable warning description. - * - * The string should be sanitized before it is used (e.g. emitted to logs or printed to - * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. */ -void WarningMessage_set_data(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKStr val); +void ClosingSigned_free(struct LDKClosingSigned this_obj); /** - * Constructs a new WarningMessage given each field + * The channel ID */ -MUST_USE_RES struct LDKWarningMessage WarningMessage_new(struct LDKChannelId channel_id_arg, struct LDKStr data_arg); +struct LDKChannelId ClosingSigned_get_channel_id(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * Creates a copy of the WarningMessage + * The channel ID */ -struct LDKWarningMessage WarningMessage_clone(const struct LDKWarningMessage *NONNULL_PTR orig); +void ClosingSigned_set_channel_id(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Generates a non-cryptographic 64-bit hash of the WarningMessage. + * The proposed total fee for the closing transaction */ -uint64_t WarningMessage_hash(const struct LDKWarningMessage *NONNULL_PTR o); +uint64_t ClosingSigned_get_fee_satoshis(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * Checks if two WarningMessages contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The proposed total fee for the closing transaction */ -bool WarningMessage_eq(const struct LDKWarningMessage *NONNULL_PTR a, const struct LDKWarningMessage *NONNULL_PTR b); +void ClosingSigned_set_fee_satoshis(struct LDKClosingSigned *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. + * A signature on the closing transaction */ -void Ping_free(struct LDKPing this_obj); +struct LDKECDSASignature ClosingSigned_get_signature(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * The desired response length. + * A signature on the closing transaction */ -uint16_t Ping_get_ponglen(const struct LDKPing *NONNULL_PTR this_ptr); +void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * The desired response length. + * The minimum and maximum fees which the sender is willing to accept, provided only by new + * nodes. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void Ping_set_ponglen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); +struct LDKClosingSignedFeeRange ClosingSigned_get_fee_range(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * The ping packet size. + * The minimum and maximum fees which the sender is willing to accept, provided only by new + * nodes. * - * This field is not sent on the wire. byteslen zeros are sent. + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint16_t Ping_get_byteslen(const struct LDKPing *NONNULL_PTR this_ptr); +void ClosingSigned_set_fee_range(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKClosingSignedFeeRange val); /** - * The ping packet size. + * Constructs a new ClosingSigned given each field * - * This field is not sent on the wire. byteslen zeros are sent. + * Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void Ping_set_byteslen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKChannelId channel_id_arg, uint64_t fee_satoshis_arg, struct LDKECDSASignature signature_arg, struct LDKClosingSignedFeeRange fee_range_arg); /** - * Constructs a new Ping given each field + * Creates a copy of the ClosingSigned */ -MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); +struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); /** - * Creates a copy of the Ping + * Generates a non-cryptographic 64-bit hash of the ClosingSigned. */ -struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); +uint64_t ClosingSigned_hash(const struct LDKClosingSigned *NONNULL_PTR o); /** - * Generates a non-cryptographic 64-bit hash of the Ping. + * Checks if two ClosingSigneds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint64_t Ping_hash(const struct LDKPing *NONNULL_PTR o); +bool ClosingSigned_eq(const struct LDKClosingSigned *NONNULL_PTR a, const struct LDKClosingSigned *NONNULL_PTR b); /** - * Checks if two Pings contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. */ -bool Ping_eq(const struct LDKPing *NONNULL_PTR a, const struct LDKPing *NONNULL_PTR b); +void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_obj); /** - * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. + * The channel ID */ -void Pong_free(struct LDKPong this_obj); +struct LDKChannelId UpdateAddHTLC_get_channel_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * The pong packet size. - * - * This field is not sent on the wire. byteslen zeros are sent. + * The channel ID */ -uint16_t Pong_get_byteslen(const struct LDKPong *NONNULL_PTR this_ptr); +void UpdateAddHTLC_set_channel_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The pong packet size. - * - * This field is not sent on the wire. byteslen zeros are sent. + * The HTLC ID */ -void Pong_set_byteslen(struct LDKPong *NONNULL_PTR this_ptr, uint16_t val); +uint64_t UpdateAddHTLC_get_htlc_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Constructs a new Pong given each field + * The HTLC ID */ -MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); +void UpdateAddHTLC_set_htlc_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the Pong + * The HTLC value in milli-satoshi */ -struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); +uint64_t UpdateAddHTLC_get_amount_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the Pong. + * The HTLC value in milli-satoshi */ -uint64_t Pong_hash(const struct LDKPong *NONNULL_PTR o); +void UpdateAddHTLC_set_amount_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if two Pongs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The payment hash, the pre-image of which controls HTLC redemption */ -bool Pong_eq(const struct LDKPong *NONNULL_PTR a, const struct LDKPong *NONNULL_PTR b); +const uint8_t (*UpdateAddHTLC_get_payment_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the CommonOpenChannelFields, if is_owned is set and inner is non-NULL. + * The payment hash, the pre-image of which controls HTLC redemption */ -void CommonOpenChannelFields_free(struct LDKCommonOpenChannelFields this_obj); +void UpdateAddHTLC_set_payment_hash(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The genesis hash of the blockchain where the channel is to be opened + * The expiry height of the HTLC */ -const uint8_t (*CommonOpenChannelFields_get_chain_hash(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr))[32]; +uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain where the channel is to be opened + * The expiry height of the HTLC */ -void CommonOpenChannelFields_set_chain_hash(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint32_t val); /** - * A temporary channel ID - * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint - * For V1 channels: a temporary channel ID, until the funding outpoint is announced + * The extra fee skimmed by the sender of this message. See + * [`ChannelConfig::accept_underpaying_htlcs`]. + * + * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs */ -struct LDKChannelId CommonOpenChannelFields_get_temporary_channel_id(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +struct LDKCOption_u64Z UpdateAddHTLC_get_skimmed_fee_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * A temporary channel ID - * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint - * For V1 channels: a temporary channel ID, until the funding outpoint is announced + * The extra fee skimmed by the sender of this message. See + * [`ChannelConfig::accept_underpaying_htlcs`]. + * + * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs */ -void CommonOpenChannelFields_set_temporary_channel_id(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKChannelId val); +void UpdateAddHTLC_set_skimmed_fee_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * For V1 channels: The channel value - * For V2 channels: Part of the channel value contributed by the channel initiator + * The onion routing packet with encrypted data for the next hop. */ -uint64_t CommonOpenChannelFields_get_funding_satoshis(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +struct LDKOnionPacket UpdateAddHTLC_get_onion_routing_packet(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * For V1 channels: The channel value - * For V2 channels: Part of the channel value contributed by the channel initiator + * The onion routing packet with encrypted data for the next hop. */ -void CommonOpenChannelFields_set_funding_satoshis(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); +void UpdateAddHTLC_set_onion_routing_packet(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKOnionPacket val); /** - * The threshold below which outputs on transactions broadcast by the channel initiator will be - * omitted + * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion + * routing packet and the recipient-provided encrypted payload within. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t CommonOpenChannelFields_get_dust_limit_satoshis(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +struct LDKPublicKey UpdateAddHTLC_get_blinding_point(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * The threshold below which outputs on transactions broadcast by the channel initiator will be - * omitted + * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion + * routing packet and the recipient-provided encrypted payload within. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void CommonOpenChannelFields_set_dust_limit_satoshis(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); +void UpdateAddHTLC_set_blinding_point(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + * Constructs a new UpdateAddHTLC given each field + * + * Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t CommonOpenChannelFields_get_max_htlc_value_in_flight_msat(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKUpdateAddHTLC UpdateAddHTLC_new(struct LDKChannelId channel_id_arg, uint64_t htlc_id_arg, uint64_t amount_msat_arg, struct LDKThirtyTwoBytes payment_hash_arg, uint32_t cltv_expiry_arg, struct LDKCOption_u64Z skimmed_fee_msat_arg, struct LDKOnionPacket onion_routing_packet_arg, struct LDKPublicKey blinding_point_arg); /** - * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + * Creates a copy of the UpdateAddHTLC */ -void CommonOpenChannelFields_set_max_htlc_value_in_flight_msat(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); +struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); /** - * The minimum HTLC size incoming to channel initiator, in milli-satoshi + * Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC. */ -uint64_t CommonOpenChannelFields_get_htlc_minimum_msat(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +uint64_t UpdateAddHTLC_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR o); /** - * The minimum HTLC size incoming to channel initiator, in milli-satoshi + * Checks if two UpdateAddHTLCs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void CommonOpenChannelFields_set_htlc_minimum_msat(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); +bool UpdateAddHTLC_eq(const struct LDKUpdateAddHTLC *NONNULL_PTR a, const struct LDKUpdateAddHTLC *NONNULL_PTR b); /** - * The feerate for the commitment transaction set by the channel initiator until updated by - * [`UpdateFee`] + * Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL. */ -uint32_t CommonOpenChannelFields_get_commitment_feerate_sat_per_1000_weight(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +void OnionMessage_free(struct LDKOnionMessage this_obj); /** - * The feerate for the commitment transaction set by the channel initiator until updated by - * [`UpdateFee`] + * Used in decrypting the onion packet's payload. */ -void CommonOpenChannelFields_set_commitment_feerate_sat_per_1000_weight(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint32_t val); +struct LDKPublicKey OnionMessage_get_blinding_point(const struct LDKOnionMessage *NONNULL_PTR this_ptr); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they - * broadcast a commitment transaction + * Used in decrypting the onion packet's payload. */ -uint16_t CommonOpenChannelFields_get_to_self_delay(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +void OnionMessage_set_blinding_point(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they - * broadcast a commitment transaction + * The full onion packet including hop data, pubkey, and hmac */ -void CommonOpenChannelFields_set_to_self_delay(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint16_t val); +struct LDKPacket OnionMessage_get_onion_routing_packet(const struct LDKOnionMessage *NONNULL_PTR this_ptr); /** - * The maximum number of inbound HTLCs towards channel initiator + * The full onion packet including hop data, pubkey, and hmac */ -uint16_t CommonOpenChannelFields_get_max_accepted_htlcs(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +void OnionMessage_set_onion_routing_packet(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPacket val); /** - * The maximum number of inbound HTLCs towards channel initiator + * Constructs a new OnionMessage given each field */ -void CommonOpenChannelFields_set_max_accepted_htlcs(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKOnionMessage OnionMessage_new(struct LDKPublicKey blinding_point_arg, struct LDKPacket onion_routing_packet_arg); /** - * The channel initiator's key controlling the funding transaction + * Creates a copy of the OnionMessage */ -struct LDKPublicKey CommonOpenChannelFields_get_funding_pubkey(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +struct LDKOnionMessage OnionMessage_clone(const struct LDKOnionMessage *NONNULL_PTR orig); /** - * The channel initiator's key controlling the funding transaction + * Generates a non-cryptographic 64-bit hash of the OnionMessage. */ -void CommonOpenChannelFields_set_funding_pubkey(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t OnionMessage_hash(const struct LDKOnionMessage *NONNULL_PTR o); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * Checks if two OnionMessages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKPublicKey CommonOpenChannelFields_get_revocation_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +bool OnionMessage_eq(const struct LDKOnionMessage *NONNULL_PTR a, const struct LDKOnionMessage *NONNULL_PTR b); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. */ -void CommonOpenChannelFields_set_revocation_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_obj); /** - * A payment key to channel initiator for transactions broadcast by counterparty + * The channel ID */ -struct LDKPublicKey CommonOpenChannelFields_get_payment_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +struct LDKChannelId UpdateFulfillHTLC_get_channel_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); /** - * A payment key to channel initiator for transactions broadcast by counterparty + * The channel ID */ -void CommonOpenChannelFields_set_payment_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UpdateFulfillHTLC_set_channel_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Used to derive a payment key to channel initiator for transactions broadcast by channel - * initiator + * The HTLC ID */ -struct LDKPublicKey CommonOpenChannelFields_get_delayed_payment_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +uint64_t UpdateFulfillHTLC_get_htlc_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); /** - * Used to derive a payment key to channel initiator for transactions broadcast by channel - * initiator + * The HTLC ID */ -void CommonOpenChannelFields_set_delayed_payment_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UpdateFulfillHTLC_set_htlc_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Used to derive an HTLC payment key to channel initiator + * The pre-image of the payment hash, allowing HTLC redemption */ -struct LDKPublicKey CommonOpenChannelFields_get_htlc_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; /** - * Used to derive an HTLC payment key to channel initiator + * The pre-image of the payment hash, allowing HTLC redemption */ -void CommonOpenChannelFields_set_htlc_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The first to-be-broadcast-by-channel-initiator transaction's per commitment point + * Constructs a new UpdateFulfillHTLC given each field */ -struct LDKPublicKey CommonOpenChannelFields_get_first_per_commitment_point(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKChannelId channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); /** - * The first to-be-broadcast-by-channel-initiator transaction's per commitment point + * Creates a copy of the UpdateFulfillHTLC */ -void CommonOpenChannelFields_set_first_per_commitment_point(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); /** - * The channel flags to be used + * Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC. */ -uint8_t CommonOpenChannelFields_get_channel_flags(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +uint64_t UpdateFulfillHTLC_hash(const struct LDKUpdateFulfillHTLC *NONNULL_PTR o); /** - * The channel flags to be used + * Checks if two UpdateFulfillHTLCs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void CommonOpenChannelFields_set_channel_flags(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint8_t val); +bool UpdateFulfillHTLC_eq(const struct LDKUpdateFulfillHTLC *NONNULL_PTR a, const struct LDKUpdateFulfillHTLC *NONNULL_PTR b); /** - * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we - * collaboratively close + * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. */ -struct LDKCOption_CVec_u8ZZ CommonOpenChannelFields_get_shutdown_scriptpubkey(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_obj); /** - * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we - * collaboratively close + * The channel ID */ -void CommonOpenChannelFields_set_shutdown_scriptpubkey(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +struct LDKChannelId UpdateFailHTLC_get_channel_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); /** - * The channel type that this channel will represent - * - * If this is `None`, we derive the channel type from the intersection of our - * feature bits with our counterparty's feature bits from the [`Init`] message. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The channel ID */ -struct LDKChannelTypeFeatures CommonOpenChannelFields_get_channel_type(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); +void UpdateFailHTLC_set_channel_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The channel type that this channel will represent - * - * If this is `None`, we derive the channel type from the intersection of our - * feature bits with our counterparty's feature bits from the [`Init`] message. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The HTLC ID */ -void CommonOpenChannelFields_set_channel_type(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); /** - * Constructs a new CommonOpenChannelFields given each field - * - * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * The HTLC ID */ -MUST_USE_RES struct LDKCommonOpenChannelFields CommonOpenChannelFields_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKChannelId temporary_channel_id_arg, uint64_t funding_satoshis_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t commitment_feerate_sat_per_1000_weight_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_basepoint_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, uint8_t channel_flags_arg, struct LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg); +void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the CommonOpenChannelFields + * Creates a copy of the UpdateFailHTLC */ -struct LDKCommonOpenChannelFields CommonOpenChannelFields_clone(const struct LDKCommonOpenChannelFields *NONNULL_PTR orig); +struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the CommonOpenChannelFields. + * Generates a non-cryptographic 64-bit hash of the UpdateFailHTLC. */ -uint64_t CommonOpenChannelFields_hash(const struct LDKCommonOpenChannelFields *NONNULL_PTR o); +uint64_t UpdateFailHTLC_hash(const struct LDKUpdateFailHTLC *NONNULL_PTR o); /** - * Checks if two CommonOpenChannelFieldss contain equal inner contents. + * Checks if two UpdateFailHTLCs contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool CommonOpenChannelFields_eq(const struct LDKCommonOpenChannelFields *NONNULL_PTR a, const struct LDKCommonOpenChannelFields *NONNULL_PTR b); +bool UpdateFailHTLC_eq(const struct LDKUpdateFailHTLC *NONNULL_PTR a, const struct LDKUpdateFailHTLC *NONNULL_PTR b); /** - * The [`ChannelParameters`] for this channel. + * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKChannelParameters CommonOpenChannelFields_channel_parameters(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_arg); +void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_obj); /** - * Frees any resources used by the ChannelParameters, if is_owned is set and inner is non-NULL. + * The channel ID */ -void ChannelParameters_free(struct LDKChannelParameters this_obj); +struct LDKChannelId UpdateFailMalformedHTLC_get_channel_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * The threshold below which outputs on transactions broadcast by the channel initiator will be - * omitted. + * The channel ID */ -uint64_t ChannelParameters_get_dust_limit_satoshis(const struct LDKChannelParameters *NONNULL_PTR this_ptr); +void UpdateFailMalformedHTLC_set_channel_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The threshold below which outputs on transactions broadcast by the channel initiator will be - * omitted. + * The HTLC ID */ -void ChannelParameters_set_dust_limit_satoshis(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); +uint64_t UpdateFailMalformedHTLC_get_htlc_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + * The HTLC ID */ -uint64_t ChannelParameters_get_max_htlc_value_in_flight_msat(const struct LDKChannelParameters *NONNULL_PTR this_ptr); +void UpdateFailMalformedHTLC_set_htlc_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + * The failure code */ -void ChannelParameters_set_max_htlc_value_in_flight_msat(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); +uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi + * The failure code */ -uint64_t ChannelParameters_get_htlc_minimum_msat(const struct LDKChannelParameters *NONNULL_PTR this_ptr); +void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint16_t val); /** - * The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi + * Creates a copy of the UpdateFailMalformedHTLC */ -void ChannelParameters_set_htlc_minimum_msat(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); /** - * The feerate for the commitment transaction set by the channel initiator until updated by - * [`UpdateFee`] + * Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC. */ -uint32_t ChannelParameters_get_commitment_feerate_sat_per_1000_weight(const struct LDKChannelParameters *NONNULL_PTR this_ptr); +uint64_t UpdateFailMalformedHTLC_hash(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR o); /** - * The feerate for the commitment transaction set by the channel initiator until updated by - * [`UpdateFee`] + * Checks if two UpdateFailMalformedHTLCs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelParameters_set_commitment_feerate_sat_per_1000_weight(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint32_t val); +bool UpdateFailMalformedHTLC_eq(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR a, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR b); /** - * The number of blocks which the non-channel-initator will have to wait to claim on-chain - * funds if they broadcast a commitment transaction. + * Frees any resources used by the CommitmentSignedBatch, if is_owned is set and inner is non-NULL. */ -uint16_t ChannelParameters_get_to_self_delay(const struct LDKChannelParameters *NONNULL_PTR this_ptr); +void CommitmentSignedBatch_free(struct LDKCommitmentSignedBatch this_obj); /** - * The number of blocks which the non-channel-initator will have to wait to claim on-chain - * funds if they broadcast a commitment transaction. + * Batch size N: all N `commitment_signed` messages must be received before being processed */ -void ChannelParameters_set_to_self_delay(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint16_t val); +uint16_t CommitmentSignedBatch_get_batch_size(const struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr); /** - * The maximum number of pending HTLCs towards the channel initiator. + * Batch size N: all N `commitment_signed` messages must be received before being processed */ -uint16_t ChannelParameters_get_max_accepted_htlcs(const struct LDKChannelParameters *NONNULL_PTR this_ptr); +void CommitmentSignedBatch_set_batch_size(struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr, uint16_t val); /** - * The maximum number of pending HTLCs towards the channel initiator. + * The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) */ -void ChannelParameters_set_max_accepted_htlcs(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint16_t val); +const uint8_t (*CommitmentSignedBatch_get_funding_txid(const struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new ChannelParameters given each field + * The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) */ -MUST_USE_RES struct LDKChannelParameters ChannelParameters_new(uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t commitment_feerate_sat_per_1000_weight_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg); +void CommitmentSignedBatch_set_funding_txid(struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the ChannelParameters + * Constructs a new CommitmentSignedBatch given each field */ -struct LDKChannelParameters ChannelParameters_clone(const struct LDKChannelParameters *NONNULL_PTR orig); +MUST_USE_RES struct LDKCommitmentSignedBatch CommitmentSignedBatch_new(uint16_t batch_size_arg, struct LDKThirtyTwoBytes funding_txid_arg); /** - * Generates a non-cryptographic 64-bit hash of the ChannelParameters. + * Creates a copy of the CommitmentSignedBatch */ -uint64_t ChannelParameters_hash(const struct LDKChannelParameters *NONNULL_PTR o); +struct LDKCommitmentSignedBatch CommitmentSignedBatch_clone(const struct LDKCommitmentSignedBatch *NONNULL_PTR orig); /** - * Checks if two ChannelParameterss contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the CommitmentSignedBatch. + */ +uint64_t CommitmentSignedBatch_hash(const struct LDKCommitmentSignedBatch *NONNULL_PTR o); + +/** + * Checks if two CommitmentSignedBatchs contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool ChannelParameters_eq(const struct LDKChannelParameters *NONNULL_PTR a, const struct LDKChannelParameters *NONNULL_PTR b); +bool CommitmentSignedBatch_eq(const struct LDKCommitmentSignedBatch *NONNULL_PTR a, const struct LDKCommitmentSignedBatch *NONNULL_PTR b); /** - * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. + * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. */ -void OpenChannel_free(struct LDKOpenChannel this_obj); +void CommitmentSigned_free(struct LDKCommitmentSigned this_obj); /** - * Common fields of `open_channel(2)`-like messages + * The channel ID */ -struct LDKCommonOpenChannelFields OpenChannel_get_common_fields(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKChannelId CommitmentSigned_get_channel_id(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * Common fields of `open_channel(2)`-like messages + * The channel ID */ -void OpenChannel_set_common_fields(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKCommonOpenChannelFields val); +void CommitmentSigned_set_channel_id(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The amount to push to the counterparty as part of the open, in milli-satoshi + * A signature on the commitment transaction */ -uint64_t OpenChannel_get_push_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKECDSASignature CommitmentSigned_get_signature(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * The amount to push to the counterparty as part of the open, in milli-satoshi + * A signature on the commitment transaction */ -void OpenChannel_set_push_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Signatures on the HTLC transactions + * + * Returns a copy of the field. */ -uint64_t OpenChannel_get_channel_reserve_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKCVec_ECDSASignatureZ CommitmentSigned_get_htlc_signatures(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Signatures on the HTLC transactions */ -void OpenChannel_set_channel_reserve_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_ECDSASignatureZ val); /** - * Constructs a new OpenChannel given each field + * Optional batch size and other parameters + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKOpenChannel OpenChannel_new(struct LDKCommonOpenChannelFields common_fields_arg, uint64_t push_msat_arg, uint64_t channel_reserve_satoshis_arg); +struct LDKCommitmentSignedBatch CommitmentSigned_get_batch(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * Creates a copy of the OpenChannel + * Optional batch size and other parameters + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); +void CommitmentSigned_set_batch(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCommitmentSignedBatch val); /** - * Generates a non-cryptographic 64-bit hash of the OpenChannel. + * Constructs a new CommitmentSigned given each field + * + * Note that batch_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t OpenChannel_hash(const struct LDKOpenChannel *NONNULL_PTR o); +MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKChannelId channel_id_arg, struct LDKECDSASignature signature_arg, struct LDKCVec_ECDSASignatureZ htlc_signatures_arg, struct LDKCommitmentSignedBatch batch_arg); /** - * Checks if two OpenChannels contain equal inner contents. + * Creates a copy of the CommitmentSigned + */ +struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the CommitmentSigned. + */ +uint64_t CommitmentSigned_hash(const struct LDKCommitmentSigned *NONNULL_PTR o); + +/** + * Checks if two CommitmentSigneds contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool OpenChannel_eq(const struct LDKOpenChannel *NONNULL_PTR a, const struct LDKOpenChannel *NONNULL_PTR b); +bool CommitmentSigned_eq(const struct LDKCommitmentSigned *NONNULL_PTR a, const struct LDKCommitmentSigned *NONNULL_PTR b); /** - * Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL. + * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. */ -void OpenChannelV2_free(struct LDKOpenChannelV2 this_obj); +void RevokeAndACK_free(struct LDKRevokeAndACK this_obj); /** - * Common fields of `open_channel(2)`-like messages + * The channel ID */ -struct LDKCommonOpenChannelFields OpenChannelV2_get_common_fields(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKChannelId RevokeAndACK_get_channel_id(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); /** - * Common fields of `open_channel(2)`-like messages + * The channel ID */ -void OpenChannelV2_set_common_fields(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKCommonOpenChannelFields val); +void RevokeAndACK_set_channel_id(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The feerate for the funding transaction set by the channel initiator + * The secret corresponding to the per-commitment point */ -uint32_t OpenChannelV2_get_funding_feerate_sat_per_1000_weight(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +const uint8_t (*RevokeAndACK_get_per_commitment_secret(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; /** - * The feerate for the funding transaction set by the channel initiator + * The secret corresponding to the per-commitment point */ -void OpenChannelV2_set_funding_feerate_sat_per_1000_weight(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); +void RevokeAndACK_set_per_commitment_secret(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The locktime for the funding transaction + * The next sender-broadcast commitment transaction's per-commitment point */ -uint32_t OpenChannelV2_get_locktime(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); /** - * The locktime for the funding transaction + * The next sender-broadcast commitment transaction's per-commitment point */ -void OpenChannelV2_set_locktime(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); +void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The second to-be-broadcast-by-channel-initiator transaction's per commitment point + * Constructs a new RevokeAndACK given each field */ -struct LDKPublicKey OpenChannelV2_get_second_per_commitment_point(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); /** - * The second to-be-broadcast-by-channel-initiator transaction's per commitment point + * Creates a copy of the RevokeAndACK */ -void OpenChannelV2_set_second_per_commitment_point(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); /** - * Optionally, a requirement that only confirmed inputs can be added + * Generates a non-cryptographic 64-bit hash of the RevokeAndACK. */ -enum LDKCOption_NoneZ OpenChannelV2_get_require_confirmed_inputs(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +uint64_t RevokeAndACK_hash(const struct LDKRevokeAndACK *NONNULL_PTR o); /** - * Optionally, a requirement that only confirmed inputs can be added + * Checks if two RevokeAndACKs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void OpenChannelV2_set_require_confirmed_inputs(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); +bool RevokeAndACK_eq(const struct LDKRevokeAndACK *NONNULL_PTR a, const struct LDKRevokeAndACK *NONNULL_PTR b); /** - * Constructs a new OpenChannelV2 given each field + * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKOpenChannelV2 OpenChannelV2_new(struct LDKCommonOpenChannelFields common_fields_arg, uint32_t funding_feerate_sat_per_1000_weight_arg, uint32_t locktime_arg, struct LDKPublicKey second_per_commitment_point_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); +void UpdateFee_free(struct LDKUpdateFee this_obj); /** - * Creates a copy of the OpenChannelV2 + * The channel ID */ -struct LDKOpenChannelV2 OpenChannelV2_clone(const struct LDKOpenChannelV2 *NONNULL_PTR orig); +struct LDKChannelId UpdateFee_get_channel_id(const struct LDKUpdateFee *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the OpenChannelV2. + * The channel ID */ -uint64_t OpenChannelV2_hash(const struct LDKOpenChannelV2 *NONNULL_PTR o); +void UpdateFee_set_channel_id(struct LDKUpdateFee *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Checks if two OpenChannelV2s contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Fee rate per 1000-weight of the transaction */ -bool OpenChannelV2_eq(const struct LDKOpenChannelV2 *NONNULL_PTR a, const struct LDKOpenChannelV2 *NONNULL_PTR b); +uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CommonAcceptChannelFields, if is_owned is set and inner is non-NULL. + * Fee rate per 1000-weight of the transaction */ -void CommonAcceptChannelFields_free(struct LDKCommonAcceptChannelFields this_obj); +void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *NONNULL_PTR this_ptr, uint32_t val); /** - * The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message. + * Constructs a new UpdateFee given each field */ -struct LDKChannelId CommonAcceptChannelFields_get_temporary_channel_id(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKChannelId channel_id_arg, uint32_t feerate_per_kw_arg); /** - * The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message. + * Creates a copy of the UpdateFee */ -void CommonAcceptChannelFields_set_temporary_channel_id(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); /** - * The threshold below which outputs on transactions broadcast by the channel acceptor will be - * omitted + * Generates a non-cryptographic 64-bit hash of the UpdateFee. */ -uint64_t CommonAcceptChannelFields_get_dust_limit_satoshis(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +uint64_t UpdateFee_hash(const struct LDKUpdateFee *NONNULL_PTR o); /** - * The threshold below which outputs on transactions broadcast by the channel acceptor will be - * omitted + * Checks if two UpdateFees contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void CommonAcceptChannelFields_set_dust_limit_satoshis(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint64_t val); +bool UpdateFee_eq(const struct LDKUpdateFee *NONNULL_PTR a, const struct LDKUpdateFee *NONNULL_PTR b); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. */ -uint64_t CommonAcceptChannelFields_get_max_htlc_value_in_flight_msat(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +void ChannelReestablish_free(struct LDKChannelReestablish this_obj); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * The channel ID */ -void CommonAcceptChannelFields_set_max_htlc_value_in_flight_msat(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint64_t val); +struct LDKChannelId ChannelReestablish_get_channel_id(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * The minimum HTLC size incoming to channel acceptor, in milli-satoshi + * The channel ID */ -uint64_t CommonAcceptChannelFields_get_htlc_minimum_msat(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +void ChannelReestablish_set_channel_id(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The minimum HTLC size incoming to channel acceptor, in milli-satoshi + * The next commitment number for the sender */ -void CommonAcceptChannelFields_set_htlc_minimum_msat(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint64_t val); +uint64_t ChannelReestablish_get_next_local_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * Minimum depth of the funding transaction before the channel is considered open + * The next commitment number for the sender */ -uint32_t CommonAcceptChannelFields_get_minimum_depth(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +void ChannelReestablish_set_next_local_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); /** - * Minimum depth of the funding transaction before the channel is considered open + * The next commitment number for the recipient */ -void CommonAcceptChannelFields_set_minimum_depth(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint32_t val); +uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they - * broadcast a commitment transaction + * The next commitment number for the recipient */ -uint16_t CommonAcceptChannelFields_get_to_self_delay(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they - * broadcast a commitment transaction + * Proof that the sender knows the per-commitment secret of a specific commitment transaction + * belonging to the recipient */ -void CommonAcceptChannelFields_set_to_self_delay(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint16_t val); +const uint8_t (*ChannelReestablish_get_your_last_per_commitment_secret(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; /** - * The maximum number of inbound HTLCs towards channel acceptor + * Proof that the sender knows the per-commitment secret of a specific commitment transaction + * belonging to the recipient */ -uint16_t CommonAcceptChannelFields_get_max_accepted_htlcs(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +void ChannelReestablish_set_your_last_per_commitment_secret(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The maximum number of inbound HTLCs towards channel acceptor + * The sender's per-commitment point for their current commitment transaction */ -void CommonAcceptChannelFields_set_max_accepted_htlcs(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint16_t val); +struct LDKPublicKey ChannelReestablish_get_my_current_per_commitment_point(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * The channel acceptor's key controlling the funding transaction + * The sender's per-commitment point for their current commitment transaction */ -struct LDKPublicKey CommonAcceptChannelFields_get_funding_pubkey(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +void ChannelReestablish_set_my_current_per_commitment_point(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The channel acceptor's key controlling the funding transaction + * The next funding transaction ID */ -void CommonAcceptChannelFields_set_funding_pubkey(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCOption_ThirtyTwoBytesZ ChannelReestablish_get_next_funding_txid(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The next funding transaction ID */ -struct LDKPublicKey CommonAcceptChannelFields_get_revocation_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +void ChannelReestablish_set_next_funding_txid(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * Constructs a new ChannelReestablish given each field */ -void CommonAcceptChannelFields_set_revocation_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKChannelReestablish ChannelReestablish_new(struct LDKChannelId channel_id_arg, uint64_t next_local_commitment_number_arg, uint64_t next_remote_commitment_number_arg, struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg, struct LDKCOption_ThirtyTwoBytesZ next_funding_txid_arg); /** - * A payment key to channel acceptor for transactions broadcast by counterparty + * Creates a copy of the ChannelReestablish */ -struct LDKPublicKey CommonAcceptChannelFields_get_payment_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); /** - * A payment key to channel acceptor for transactions broadcast by counterparty + * Generates a non-cryptographic 64-bit hash of the ChannelReestablish. */ -void CommonAcceptChannelFields_set_payment_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t ChannelReestablish_hash(const struct LDKChannelReestablish *NONNULL_PTR o); /** - * Used to derive a payment key to channel acceptor for transactions broadcast by channel - * acceptor + * Checks if two ChannelReestablishs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKPublicKey CommonAcceptChannelFields_get_delayed_payment_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +bool ChannelReestablish_eq(const struct LDKChannelReestablish *NONNULL_PTR a, const struct LDKChannelReestablish *NONNULL_PTR b); /** - * Used to derive a payment key to channel acceptor for transactions broadcast by channel - * acceptor + * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. */ -void CommonAcceptChannelFields_set_delayed_payment_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_obj); /** - * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty + * The channel ID */ -struct LDKPublicKey CommonAcceptChannelFields_get_htlc_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +struct LDKChannelId AnnouncementSignatures_get_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty + * The channel ID */ -void CommonAcceptChannelFields_set_htlc_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void AnnouncementSignatures_set_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point + * The short channel ID */ -struct LDKPublicKey CommonAcceptChannelFields_get_first_per_commitment_point(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +uint64_t AnnouncementSignatures_get_short_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point + * The short channel ID */ -void CommonAcceptChannelFields_set_first_per_commitment_point(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void AnnouncementSignatures_set_short_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, uint64_t val); /** - * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we - * collaboratively close + * A signature by the node key */ -struct LDKCOption_CVec_u8ZZ CommonAcceptChannelFields_get_shutdown_scriptpubkey(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +struct LDKECDSASignature AnnouncementSignatures_get_node_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we - * collaboratively close + * A signature by the node key */ -void CommonAcceptChannelFields_set_shutdown_scriptpubkey(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +void AnnouncementSignatures_set_node_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * The channel type that this channel will represent. If none is set, we derive the channel - * type from the intersection of our feature bits with our counterparty's feature bits from - * the Init message. - * - * This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s - * [`CommonOpenChannelFields::channel_type`]. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * A signature by the funding key */ -struct LDKChannelTypeFeatures CommonAcceptChannelFields_get_channel_type(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); +struct LDKECDSASignature AnnouncementSignatures_get_bitcoin_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * The channel type that this channel will represent. If none is set, we derive the channel - * type from the intersection of our feature bits with our counterparty's feature bits from - * the Init message. - * - * This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s - * [`CommonOpenChannelFields::channel_type`]. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * A signature by the funding key */ -void CommonAcceptChannelFields_set_channel_type(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * Constructs a new CommonAcceptChannelFields given each field - * - * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new AnnouncementSignatures given each field */ -MUST_USE_RES struct LDKCommonAcceptChannelFields CommonAcceptChannelFields_new(struct LDKChannelId temporary_channel_id_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t minimum_depth_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_basepoint_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, struct LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg); +MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKChannelId channel_id_arg, uint64_t short_channel_id_arg, struct LDKECDSASignature node_signature_arg, struct LDKECDSASignature bitcoin_signature_arg); /** - * Creates a copy of the CommonAcceptChannelFields + * Creates a copy of the AnnouncementSignatures */ -struct LDKCommonAcceptChannelFields CommonAcceptChannelFields_clone(const struct LDKCommonAcceptChannelFields *NONNULL_PTR orig); +struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the CommonAcceptChannelFields. + * Generates a non-cryptographic 64-bit hash of the AnnouncementSignatures. */ -uint64_t CommonAcceptChannelFields_hash(const struct LDKCommonAcceptChannelFields *NONNULL_PTR o); +uint64_t AnnouncementSignatures_hash(const struct LDKAnnouncementSignatures *NONNULL_PTR o); /** - * Checks if two CommonAcceptChannelFieldss contain equal inner contents. + * Checks if two AnnouncementSignaturess contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool CommonAcceptChannelFields_eq(const struct LDKCommonAcceptChannelFields *NONNULL_PTR a, const struct LDKCommonAcceptChannelFields *NONNULL_PTR b); +bool AnnouncementSignatures_eq(const struct LDKAnnouncementSignatures *NONNULL_PTR a, const struct LDKAnnouncementSignatures *NONNULL_PTR b); /** - * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. + * Frees any resources used by the SocketAddress */ -void AcceptChannel_free(struct LDKAcceptChannel this_obj); +void SocketAddress_free(struct LDKSocketAddress this_ptr); /** - * Common fields of `accept_channel(2)`-like messages + * Creates a copy of the SocketAddress */ -struct LDKCommonAcceptChannelFields AcceptChannel_get_common_fields(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKSocketAddress SocketAddress_clone(const struct LDKSocketAddress *NONNULL_PTR orig); /** - * Common fields of `accept_channel(2)`-like messages + * Utility method to constructs a new TcpIpV4-variant SocketAddress */ -void AcceptChannel_set_common_fields(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKCommonAcceptChannelFields val); +struct LDKSocketAddress SocketAddress_tcp_ip_v4(struct LDKFourBytes addr, uint16_t port); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Utility method to constructs a new TcpIpV6-variant SocketAddress */ -uint64_t AcceptChannel_get_channel_reserve_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKSocketAddress SocketAddress_tcp_ip_v6(struct LDKSixteenBytes addr, uint16_t port); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Utility method to constructs a new OnionV2-variant SocketAddress */ -void AcceptChannel_set_channel_reserve_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKSocketAddress SocketAddress_onion_v2(struct LDKTwelveBytes a); /** - * Constructs a new AcceptChannel given each field + * Utility method to constructs a new OnionV3-variant SocketAddress */ -MUST_USE_RES struct LDKAcceptChannel AcceptChannel_new(struct LDKCommonAcceptChannelFields common_fields_arg, uint64_t channel_reserve_satoshis_arg); +struct LDKSocketAddress SocketAddress_onion_v3(struct LDKThirtyTwoBytes ed25519_pubkey, uint16_t checksum, uint8_t version, uint16_t port); /** - * Creates a copy of the AcceptChannel + * Utility method to constructs a new Hostname-variant SocketAddress */ -struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); +struct LDKSocketAddress SocketAddress_hostname(struct LDKHostname hostname, uint16_t port); /** - * Generates a non-cryptographic 64-bit hash of the AcceptChannel. + * Generates a non-cryptographic 64-bit hash of the SocketAddress. */ -uint64_t AcceptChannel_hash(const struct LDKAcceptChannel *NONNULL_PTR o); +uint64_t SocketAddress_hash(const struct LDKSocketAddress *NONNULL_PTR o); /** - * Checks if two AcceptChannels contain equal inner contents. + * Checks if two SocketAddresss contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. */ -bool AcceptChannel_eq(const struct LDKAcceptChannel *NONNULL_PTR a, const struct LDKAcceptChannel *NONNULL_PTR b); +bool SocketAddress_eq(const struct LDKSocketAddress *NONNULL_PTR a, const struct LDKSocketAddress *NONNULL_PTR b); /** - * Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL. + * Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read */ -void AcceptChannelV2_free(struct LDKAcceptChannelV2 this_obj); +struct LDKCVec_u8Z SocketAddress_write(const struct LDKSocketAddress *NONNULL_PTR obj); /** - * Common fields of `accept_channel(2)`-like messages + * Read a SocketAddress from a byte array, created by SocketAddress_write */ -struct LDKCommonAcceptChannelFields AcceptChannelV2_get_common_fields(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +struct LDKCResult_SocketAddressDecodeErrorZ SocketAddress_read(struct LDKu8slice ser); /** - * Common fields of `accept_channel(2)`-like messages + * Creates a copy of the SocketAddressParseError */ -void AcceptChannelV2_set_common_fields(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKCommonAcceptChannelFields val); +enum LDKSocketAddressParseError SocketAddressParseError_clone(const enum LDKSocketAddressParseError *NONNULL_PTR orig); /** - * Part of the channel value contributed by the channel acceptor + * Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError */ -uint64_t AcceptChannelV2_get_funding_satoshis(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +enum LDKSocketAddressParseError SocketAddressParseError_socket_addr_parse(void); /** - * Part of the channel value contributed by the channel acceptor + * Utility method to constructs a new InvalidInput-variant SocketAddressParseError */ -void AcceptChannelV2_set_funding_satoshis(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint64_t val); +enum LDKSocketAddressParseError SocketAddressParseError_invalid_input(void); /** - * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point + * Utility method to constructs a new InvalidPort-variant SocketAddressParseError */ -struct LDKPublicKey AcceptChannelV2_get_second_per_commitment_point(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +enum LDKSocketAddressParseError SocketAddressParseError_invalid_port(void); /** - * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point + * Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError */ -void AcceptChannelV2_set_second_per_commitment_point(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +enum LDKSocketAddressParseError SocketAddressParseError_invalid_onion_v3(void); /** - * Optionally, a requirement that only confirmed inputs can be added + * Generates a non-cryptographic 64-bit hash of the SocketAddressParseError. */ -enum LDKCOption_NoneZ AcceptChannelV2_get_require_confirmed_inputs(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +uint64_t SocketAddressParseError_hash(const enum LDKSocketAddressParseError *NONNULL_PTR o); /** - * Optionally, a requirement that only confirmed inputs can be added + * Checks if two SocketAddressParseErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void AcceptChannelV2_set_require_confirmed_inputs(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); +bool SocketAddressParseError_eq(const enum LDKSocketAddressParseError *NONNULL_PTR a, const enum LDKSocketAddressParseError *NONNULL_PTR b); /** - * Constructs a new AcceptChannelV2 given each field + * Get the string representation of a SocketAddressParseError object */ -MUST_USE_RES struct LDKAcceptChannelV2 AcceptChannelV2_new(struct LDKCommonAcceptChannelFields common_fields_arg, uint64_t funding_satoshis_arg, struct LDKPublicKey second_per_commitment_point_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); +struct LDKStr SocketAddressParseError_to_str(const enum LDKSocketAddressParseError *NONNULL_PTR o); /** - * Creates a copy of the AcceptChannelV2 + * Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`]. + * + * The host part must end with \".onion\". */ -struct LDKAcceptChannelV2 AcceptChannelV2_clone(const struct LDKAcceptChannelV2 *NONNULL_PTR orig); +struct LDKCResult_SocketAddressSocketAddressParseErrorZ parse_onion_address(struct LDKStr host, uint16_t port); /** - * Generates a non-cryptographic 64-bit hash of the AcceptChannelV2. + * Get the string representation of a SocketAddress object */ -uint64_t AcceptChannelV2_hash(const struct LDKAcceptChannelV2 *NONNULL_PTR o); +struct LDKStr SocketAddress_to_str(const struct LDKSocketAddress *NONNULL_PTR o); /** - * Checks if two AcceptChannelV2s contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a SocketAddress object from a string */ -bool AcceptChannelV2_eq(const struct LDKAcceptChannelV2 *NONNULL_PTR a, const struct LDKAcceptChannelV2 *NONNULL_PTR b); +struct LDKCResult_SocketAddressSocketAddressParseErrorZ SocketAddress_from_str(struct LDKStr s); /** - * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. + * Frees any resources used by the UnsignedGossipMessage */ -void FundingCreated_free(struct LDKFundingCreated this_obj); +void UnsignedGossipMessage_free(struct LDKUnsignedGossipMessage this_ptr); /** - * A temporary channel ID, until the funding is established + * Creates a copy of the UnsignedGossipMessage */ -struct LDKChannelId FundingCreated_get_temporary_channel_id(const struct LDKFundingCreated *NONNULL_PTR this_ptr); +struct LDKUnsignedGossipMessage UnsignedGossipMessage_clone(const struct LDKUnsignedGossipMessage *NONNULL_PTR orig); /** - * A temporary channel ID, until the funding is established + * Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage */ -void FundingCreated_set_temporary_channel_id(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_announcement(struct LDKUnsignedChannelAnnouncement a); /** - * The funding transaction ID + * Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage */ -const uint8_t (*FundingCreated_get_funding_txid(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; +struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_update(struct LDKUnsignedChannelUpdate a); /** - * The funding transaction ID + * Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage */ -void FundingCreated_set_funding_txid(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKUnsignedGossipMessage UnsignedGossipMessage_node_announcement(struct LDKUnsignedNodeAnnouncement a); /** - * The specific output index funding this channel + * Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read */ -uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UnsignedGossipMessage_write(const struct LDKUnsignedGossipMessage *NONNULL_PTR obj); /** - * The specific output index funding this channel + * Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. */ -void FundingCreated_set_funding_output_index(struct LDKFundingCreated *NONNULL_PTR this_ptr, uint16_t val); +void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj); /** - * The signature of the channel initiator (funder) on the initial commitment transaction + * The advertised features */ -struct LDKECDSASignature FundingCreated_get_signature(const struct LDKFundingCreated *NONNULL_PTR this_ptr); +struct LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The signature of the channel initiator (funder) on the initial commitment transaction + * The advertised features */ -void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void UnsignedNodeAnnouncement_set_features(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * Constructs a new FundingCreated given each field + * A strictly monotonic announcement counter, with gaps allowed */ -MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKChannelId temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKECDSASignature signature_arg); +uint32_t UnsignedNodeAnnouncement_get_timestamp(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Creates a copy of the FundingCreated + * A strictly monotonic announcement counter, with gaps allowed */ -struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); +void UnsignedNodeAnnouncement_set_timestamp(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, uint32_t val); /** - * Generates a non-cryptographic 64-bit hash of the FundingCreated. + * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back + * to this node). */ -uint64_t FundingCreated_hash(const struct LDKFundingCreated *NONNULL_PTR o); +struct LDKNodeId UnsignedNodeAnnouncement_get_node_id(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Checks if two FundingCreateds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back + * to this node). */ -bool FundingCreated_eq(const struct LDKFundingCreated *NONNULL_PTR a, const struct LDKFundingCreated *NONNULL_PTR b); +void UnsignedNodeAnnouncement_set_node_id(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. + * An RGB color for UI purposes */ -void FundingSigned_free(struct LDKFundingSigned this_obj); +const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[3]; /** - * The channel ID + * An RGB color for UI purposes */ -struct LDKChannelId FundingSigned_get_channel_id(const struct LDKFundingSigned *NONNULL_PTR this_ptr); +void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThreeBytes val); /** - * The channel ID + * An alias, for UI purposes. + * + * This should be sanitized before use. There is no guarantee of uniqueness. */ -void FundingSigned_set_channel_id(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKNodeAlias UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The signature of the channel acceptor (fundee) on the initial commitment transaction + * An alias, for UI purposes. + * + * This should be sanitized before use. There is no guarantee of uniqueness. */ -struct LDKECDSASignature FundingSigned_get_signature(const struct LDKFundingSigned *NONNULL_PTR this_ptr); +void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeAlias val); /** - * The signature of the channel acceptor (fundee) on the initial commitment transaction + * List of addresses on which this node is reachable + * + * Returns a copy of the field. */ -void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +struct LDKCVec_SocketAddressZ UnsignedNodeAnnouncement_get_addresses(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Constructs a new FundingSigned given each field + * List of addresses on which this node is reachable */ -MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKChannelId channel_id_arg, struct LDKECDSASignature signature_arg); +void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_SocketAddressZ val); /** - * Creates a copy of the FundingSigned + * Excess address data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol. + * + * Returns a copy of the field. */ -struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); +struct LDKCVec_u8Z UnsignedNodeAnnouncement_get_excess_address_data(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the FundingSigned. + * Excess address data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol. */ -uint64_t FundingSigned_hash(const struct LDKFundingSigned *NONNULL_PTR o); +void UnsignedNodeAnnouncement_set_excess_address_data(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Checks if two FundingSigneds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * + * Returns a copy of the field. */ -bool FundingSigned_eq(const struct LDKFundingSigned *NONNULL_PTR a, const struct LDKFundingSigned *NONNULL_PTR b); +struct LDKCVec_u8Z UnsignedNodeAnnouncement_get_excess_data(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL. + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. */ -void ChannelReady_free(struct LDKChannelReady this_obj); +void UnsignedNodeAnnouncement_set_excess_data(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * The channel ID + * Constructs a new UnsignedNodeAnnouncement given each field */ -struct LDKChannelId ChannelReady_get_channel_id(const struct LDKChannelReady *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_new(struct LDKNodeFeatures features_arg, uint32_t timestamp_arg, struct LDKNodeId node_id_arg, struct LDKThreeBytes rgb_arg, struct LDKNodeAlias alias_arg, struct LDKCVec_SocketAddressZ addresses_arg, struct LDKCVec_u8Z excess_address_data_arg, struct LDKCVec_u8Z excess_data_arg); /** - * The channel ID + * Creates a copy of the UnsignedNodeAnnouncement */ -void ChannelReady_set_channel_id(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); /** - * The per-commitment point of the second commitment transaction + * Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement. */ -struct LDKPublicKey ChannelReady_get_next_per_commitment_point(const struct LDKChannelReady *NONNULL_PTR this_ptr); +uint64_t UnsignedNodeAnnouncement_hash(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR o); /** - * The per-commitment point of the second commitment transaction + * Checks if two UnsignedNodeAnnouncements contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelReady_set_next_per_commitment_point(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKPublicKey val); +bool UnsignedNodeAnnouncement_eq(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR a, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR b); /** - * If set, provides a `short_channel_id` alias for this channel. - * - * The sender will accept payments to be forwarded over this SCID and forward them to this - * messages' recipient. + * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. */ -struct LDKCOption_u64Z ChannelReady_get_short_channel_id_alias(const struct LDKChannelReady *NONNULL_PTR this_ptr); +void NodeAnnouncement_free(struct LDKNodeAnnouncement this_obj); /** - * If set, provides a `short_channel_id` alias for this channel. - * - * The sender will accept payments to be forwarded over this SCID and forward them to this - * messages' recipient. + * The signature by the node key */ -void ChannelReady_set_short_channel_id_alias(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKECDSASignature NodeAnnouncement_get_signature(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Constructs a new ChannelReady given each field + * The signature by the node key */ -MUST_USE_RES struct LDKChannelReady ChannelReady_new(struct LDKChannelId channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg, struct LDKCOption_u64Z short_channel_id_alias_arg); +void NodeAnnouncement_set_signature(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * Creates a copy of the ChannelReady + * The actual content of the announcement */ -struct LDKChannelReady ChannelReady_clone(const struct LDKChannelReady *NONNULL_PTR orig); +struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the ChannelReady. + * The actual content of the announcement */ -uint64_t ChannelReady_hash(const struct LDKChannelReady *NONNULL_PTR o); +void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedNodeAnnouncement val); /** - * Checks if two ChannelReadys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constructs a new NodeAnnouncement given each field */ -bool ChannelReady_eq(const struct LDKChannelReady *NONNULL_PTR a, const struct LDKChannelReady *NONNULL_PTR b); +MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKECDSASignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); /** - * Frees any resources used by the Stfu, if is_owned is set and inner is non-NULL. + * Creates a copy of the NodeAnnouncement */ -void Stfu_free(struct LDKStfu this_obj); +struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); /** - * The channel ID where quiescence is intended + * Generates a non-cryptographic 64-bit hash of the NodeAnnouncement. */ -struct LDKChannelId Stfu_get_channel_id(const struct LDKStfu *NONNULL_PTR this_ptr); +uint64_t NodeAnnouncement_hash(const struct LDKNodeAnnouncement *NONNULL_PTR o); /** - * The channel ID where quiescence is intended + * Checks if two NodeAnnouncements contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void Stfu_set_channel_id(struct LDKStfu *NONNULL_PTR this_ptr, struct LDKChannelId val); +bool NodeAnnouncement_eq(const struct LDKNodeAnnouncement *NONNULL_PTR a, const struct LDKNodeAnnouncement *NONNULL_PTR b); /** - * Initiator flag, 1 if initiating, 0 if replying to an stfu. + * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. */ -uint8_t Stfu_get_initiator(const struct LDKStfu *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_obj); /** - * Initiator flag, 1 if initiating, 0 if replying to an stfu. + * The advertised channel features */ -void Stfu_set_initiator(struct LDKStfu *NONNULL_PTR this_ptr, uint8_t val); +struct LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Constructs a new Stfu given each field + * The advertised channel features */ -MUST_USE_RES struct LDKStfu Stfu_new(struct LDKChannelId channel_id_arg, uint8_t initiator_arg); +void UnsignedChannelAnnouncement_set_features(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * Creates a copy of the Stfu + * The genesis hash of the blockchain where the channel is to be opened */ -struct LDKStfu Stfu_clone(const struct LDKStfu *NONNULL_PTR orig); +const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr))[32]; /** - * Checks if two Stfus contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The genesis hash of the blockchain where the channel is to be opened */ -bool Stfu_eq(const struct LDKStfu *NONNULL_PTR a, const struct LDKStfu *NONNULL_PTR b); +void UnsignedChannelAnnouncement_set_chain_hash(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the SpliceInit, if is_owned is set and inner is non-NULL. + * The short channel ID */ -void SpliceInit_free(struct LDKSpliceInit this_obj); +uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The channel ID where splicing is intended + * The short channel ID */ -struct LDKChannelId SpliceInit_get_channel_id(const struct LDKSpliceInit *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_set_short_channel_id(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, uint64_t val); /** - * The channel ID where splicing is intended + * One of the two `node_id`s which are endpoints of this channel */ -void SpliceInit_set_channel_id(struct LDKSpliceInit *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The amount the splice initiator is intending to add to its channel balance (splice-in) - * or remove from its channel balance (splice-out). + * One of the two `node_id`s which are endpoints of this channel */ -int64_t SpliceInit_get_funding_contribution_satoshis(const struct LDKSpliceInit *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_set_node_id_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * The amount the splice initiator is intending to add to its channel balance (splice-in) - * or remove from its channel balance (splice-out). + * The other of the two `node_id`s which are endpoints of this channel */ -void SpliceInit_set_funding_contribution_satoshis(struct LDKSpliceInit *NONNULL_PTR this_ptr, int64_t val); +struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The feerate for the new funding transaction, set by the splice initiator + * The other of the two `node_id`s which are endpoints of this channel */ -uint32_t SpliceInit_get_funding_feerate_perkw(const struct LDKSpliceInit *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_set_node_id_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * The feerate for the new funding transaction, set by the splice initiator + * The funding key for the first node */ -void SpliceInit_set_funding_feerate_perkw(struct LDKSpliceInit *NONNULL_PTR this_ptr, uint32_t val); +struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The locktime for the new funding transaction + * The funding key for the first node */ -uint32_t SpliceInit_get_locktime(const struct LDKSpliceInit *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_set_bitcoin_key_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * The locktime for the new funding transaction + * The funding key for the second node */ -void SpliceInit_set_locktime(struct LDKSpliceInit *NONNULL_PTR this_ptr, uint32_t val); +struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The key of the sender (splice initiator) controlling the new funding transaction + * The funding key for the second node */ -struct LDKPublicKey SpliceInit_get_funding_pubkey(const struct LDKSpliceInit *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * The key of the sender (splice initiator) controlling the new funding transaction + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * + * Returns a copy of the field. */ -void SpliceInit_set_funding_pubkey(struct LDKSpliceInit *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCVec_u8Z UnsignedChannelAnnouncement_get_excess_data(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * If set, only confirmed inputs added (by the splice acceptor) will be accepted + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. */ -enum LDKCOption_NoneZ SpliceInit_get_require_confirmed_inputs(const struct LDKSpliceInit *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_set_excess_data(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * If set, only confirmed inputs added (by the splice acceptor) will be accepted + * Constructs a new UnsignedChannelAnnouncement given each field */ -void SpliceInit_set_require_confirmed_inputs(struct LDKSpliceInit *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); +MUST_USE_RES struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_new(struct LDKChannelFeatures features_arg, struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, struct LDKNodeId node_id_1_arg, struct LDKNodeId node_id_2_arg, struct LDKNodeId bitcoin_key_1_arg, struct LDKNodeId bitcoin_key_2_arg, struct LDKCVec_u8Z excess_data_arg); /** - * Constructs a new SpliceInit given each field + * Creates a copy of the UnsignedChannelAnnouncement */ -MUST_USE_RES struct LDKSpliceInit SpliceInit_new(struct LDKChannelId channel_id_arg, int64_t funding_contribution_satoshis_arg, uint32_t funding_feerate_perkw_arg, uint32_t locktime_arg, struct LDKPublicKey funding_pubkey_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); +struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); /** - * Creates a copy of the SpliceInit + * Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement. */ -struct LDKSpliceInit SpliceInit_clone(const struct LDKSpliceInit *NONNULL_PTR orig); +uint64_t UnsignedChannelAnnouncement_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR o); /** - * Checks if two SpliceInits contain equal inner contents. + * Checks if two UnsignedChannelAnnouncements contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool SpliceInit_eq(const struct LDKSpliceInit *NONNULL_PTR a, const struct LDKSpliceInit *NONNULL_PTR b); +bool UnsignedChannelAnnouncement_eq(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR a, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR b); /** - * Frees any resources used by the SpliceAck, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. */ -void SpliceAck_free(struct LDKSpliceAck this_obj); +void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_obj); /** - * The channel ID where splicing is intended + * Authentication of the announcement by the first public node */ -struct LDKChannelId SpliceAck_get_channel_id(const struct LDKSpliceAck *NONNULL_PTR this_ptr); +struct LDKECDSASignature ChannelAnnouncement_get_node_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The channel ID where splicing is intended + * Authentication of the announcement by the first public node */ -void SpliceAck_set_channel_id(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKChannelId val); +void ChannelAnnouncement_set_node_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * The amount the splice acceptor is intending to add to its channel balance (splice-in) - * or remove from its channel balance (splice-out). + * Authentication of the announcement by the second public node */ -int64_t SpliceAck_get_funding_contribution_satoshis(const struct LDKSpliceAck *NONNULL_PTR this_ptr); +struct LDKECDSASignature ChannelAnnouncement_get_node_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The amount the splice acceptor is intending to add to its channel balance (splice-in) - * or remove from its channel balance (splice-out). + * Authentication of the announcement by the second public node */ -void SpliceAck_set_funding_contribution_satoshis(struct LDKSpliceAck *NONNULL_PTR this_ptr, int64_t val); +void ChannelAnnouncement_set_node_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * The key of the sender (splice acceptor) controlling the new funding transaction + * Proof of funding UTXO ownership by the first public node */ -struct LDKPublicKey SpliceAck_get_funding_pubkey(const struct LDKSpliceAck *NONNULL_PTR this_ptr); +struct LDKECDSASignature ChannelAnnouncement_get_bitcoin_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The key of the sender (splice acceptor) controlling the new funding transaction + * Proof of funding UTXO ownership by the first public node */ -void SpliceAck_set_funding_pubkey(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void ChannelAnnouncement_set_bitcoin_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * If set, only confirmed inputs added (by the splice initiator) will be accepted + * Proof of funding UTXO ownership by the second public node */ -enum LDKCOption_NoneZ SpliceAck_get_require_confirmed_inputs(const struct LDKSpliceAck *NONNULL_PTR this_ptr); +struct LDKECDSASignature ChannelAnnouncement_get_bitcoin_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * If set, only confirmed inputs added (by the splice initiator) will be accepted + * Proof of funding UTXO ownership by the second public node */ -void SpliceAck_set_require_confirmed_inputs(struct LDKSpliceAck *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); +void ChannelAnnouncement_set_bitcoin_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * Constructs a new SpliceAck given each field + * The actual announcement */ -MUST_USE_RES struct LDKSpliceAck SpliceAck_new(struct LDKChannelId channel_id_arg, int64_t funding_contribution_satoshis_arg, struct LDKPublicKey funding_pubkey_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); +struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Creates a copy of the SpliceAck + * The actual announcement */ -struct LDKSpliceAck SpliceAck_clone(const struct LDKSpliceAck *NONNULL_PTR orig); +void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedChannelAnnouncement val); /** - * Checks if two SpliceAcks contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constructs a new ChannelAnnouncement given each field */ -bool SpliceAck_eq(const struct LDKSpliceAck *NONNULL_PTR a, const struct LDKSpliceAck *NONNULL_PTR b); +MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKECDSASignature node_signature_1_arg, struct LDKECDSASignature node_signature_2_arg, struct LDKECDSASignature bitcoin_signature_1_arg, struct LDKECDSASignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); /** - * Frees any resources used by the SpliceLocked, if is_owned is set and inner is non-NULL. + * Creates a copy of the ChannelAnnouncement */ -void SpliceLocked_free(struct LDKSpliceLocked this_obj); +struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); /** - * The channel ID + * Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement. */ -struct LDKChannelId SpliceLocked_get_channel_id(const struct LDKSpliceLocked *NONNULL_PTR this_ptr); +uint64_t ChannelAnnouncement_hash(const struct LDKChannelAnnouncement *NONNULL_PTR o); /** - * The channel ID + * Checks if two ChannelAnnouncements contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void SpliceLocked_set_channel_id(struct LDKSpliceLocked *NONNULL_PTR this_ptr, struct LDKChannelId val); +bool ChannelAnnouncement_eq(const struct LDKChannelAnnouncement *NONNULL_PTR a, const struct LDKChannelAnnouncement *NONNULL_PTR b); /** - * The ID of the new funding transaction that has been locked + * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. */ -const uint8_t (*SpliceLocked_get_splice_txid(const struct LDKSpliceLocked *NONNULL_PTR this_ptr))[32]; +void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_obj); /** - * The ID of the new funding transaction that has been locked + * The genesis hash of the blockchain where the channel is to be opened */ -void SpliceLocked_set_splice_txid(struct LDKSpliceLocked *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new SpliceLocked given each field + * The genesis hash of the blockchain where the channel is to be opened */ -MUST_USE_RES struct LDKSpliceLocked SpliceLocked_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes splice_txid_arg); +void UnsignedChannelUpdate_set_chain_hash(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the SpliceLocked + * The short channel ID */ -struct LDKSpliceLocked SpliceLocked_clone(const struct LDKSpliceLocked *NONNULL_PTR orig); +uint64_t UnsignedChannelUpdate_get_short_channel_id(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Checks if two SpliceLockeds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The short channel ID */ -bool SpliceLocked_eq(const struct LDKSpliceLocked *NONNULL_PTR a, const struct LDKSpliceLocked *NONNULL_PTR b); +void UnsignedChannelUpdate_set_short_channel_id(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL. + * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -void TxAddInput_free(struct LDKTxAddInput this_obj); +uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The channel ID + * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -struct LDKChannelId TxAddInput_get_channel_id(const struct LDKTxAddInput *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * The channel ID + * Flags pertaining to this message. */ -void TxAddInput_set_channel_id(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKChannelId val); +uint8_t UnsignedChannelUpdate_get_message_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * A randomly chosen unique identifier for this input, which is even for initiators and odd for - * non-initiators. + * Flags pertaining to this message. */ -uint64_t TxAddInput_get_serial_id(const struct LDKTxAddInput *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_message_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); /** - * A randomly chosen unique identifier for this input, which is even for initiators and odd for - * non-initiators. + * Flags pertaining to the channel, including to which direction in the channel this update + * applies and whether the direction is currently able to forward HTLCs. */ -void TxAddInput_set_serial_id(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint64_t val); +uint8_t UnsignedChannelUpdate_get_channel_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Serialized transaction that contains the output this input spends to verify that it is non - * malleable. + * Flags pertaining to the channel, including to which direction in the channel this update + * applies and whether the direction is currently able to forward HTLCs. */ -struct LDKTransactionU16LenLimited TxAddInput_get_prevtx(const struct LDKTxAddInput *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_channel_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); /** - * Serialized transaction that contains the output this input spends to verify that it is non - * malleable. + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines + * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a + * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, + * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ -void TxAddInput_set_prevtx(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKTransactionU16LenLimited val); +uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The index of the output being spent + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines + * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a + * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, + * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ -uint32_t TxAddInput_get_prevtx_out(const struct LDKTxAddInput *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint16_t val); /** - * The index of the output being spent + * The minimum HTLC size incoming to sender, in milli-satoshi */ -void TxAddInput_set_prevtx_out(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint32_t val); +uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The sequence number of this input + * The minimum HTLC size incoming to sender, in milli-satoshi */ -uint32_t TxAddInput_get_sequence(const struct LDKTxAddInput *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_htlc_minimum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * The sequence number of this input + * The maximum HTLC value incoming to sender, in milli-satoshi. + * + * This used to be optional. */ -void TxAddInput_set_sequence(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint32_t val); +uint64_t UnsignedChannelUpdate_get_htlc_maximum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The ID of the previous funding transaction, when it is being added as an input during splicing + * The maximum HTLC value incoming to sender, in milli-satoshi. + * + * This used to be optional. */ -struct LDKCOption_ThirtyTwoBytesZ TxAddInput_get_shared_input_txid(const struct LDKTxAddInput *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_htlc_maximum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * The ID of the previous funding transaction, when it is being added as an input during splicing + * The base HTLC fee charged by sender, in milli-satoshi */ -void TxAddInput_set_shared_input_txid(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); +uint32_t UnsignedChannelUpdate_get_fee_base_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Constructs a new TxAddInput given each field + * The base HTLC fee charged by sender, in milli-satoshi */ -MUST_USE_RES struct LDKTxAddInput TxAddInput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg, struct LDKTransactionU16LenLimited prevtx_arg, uint32_t prevtx_out_arg, uint32_t sequence_arg, struct LDKCOption_ThirtyTwoBytesZ shared_input_txid_arg); +void UnsignedChannelUpdate_set_fee_base_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a copy of the TxAddInput + * The amount to fee multiplier, in micro-satoshi */ -struct LDKTxAddInput TxAddInput_clone(const struct LDKTxAddInput *NONNULL_PTR orig); +uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the TxAddInput. + * The amount to fee multiplier, in micro-satoshi */ -uint64_t TxAddInput_hash(const struct LDKTxAddInput *NONNULL_PTR o); +void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if two TxAddInputs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * + * Returns a copy of the field. */ -bool TxAddInput_eq(const struct LDKTxAddInput *NONNULL_PTR a, const struct LDKTxAddInput *NONNULL_PTR b); +struct LDKCVec_u8Z UnsignedChannelUpdate_get_excess_data(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL. + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. */ -void TxAddOutput_free(struct LDKTxAddOutput this_obj); +void UnsignedChannelUpdate_set_excess_data(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * The channel ID + * Constructs a new UnsignedChannelUpdate given each field */ -struct LDKChannelId TxAddOutput_get_channel_id(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_new(struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, uint32_t timestamp_arg, uint8_t message_flags_arg, uint8_t channel_flags_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, struct LDKCVec_u8Z excess_data_arg); /** - * The channel ID + * Creates a copy of the UnsignedChannelUpdate */ -void TxAddOutput_set_channel_id(struct LDKTxAddOutput *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); /** - * A randomly chosen unique identifier for this output, which is even for initiators and odd for - * non-initiators. + * Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate. */ -uint64_t TxAddOutput_get_serial_id(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); +uint64_t UnsignedChannelUpdate_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR o); /** - * A randomly chosen unique identifier for this output, which is even for initiators and odd for - * non-initiators. + * Checks if two UnsignedChannelUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void TxAddOutput_set_serial_id(struct LDKTxAddOutput *NONNULL_PTR this_ptr, uint64_t val); +bool UnsignedChannelUpdate_eq(const struct LDKUnsignedChannelUpdate *NONNULL_PTR a, const struct LDKUnsignedChannelUpdate *NONNULL_PTR b); /** - * The satoshi value of the output + * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. */ -uint64_t TxAddOutput_get_sats(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); +void ChannelUpdate_free(struct LDKChannelUpdate this_obj); /** - * The satoshi value of the output + * A signature of the channel update */ -void TxAddOutput_set_sats(struct LDKTxAddOutput *NONNULL_PTR this_ptr, uint64_t val); +struct LDKECDSASignature ChannelUpdate_get_signature(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); /** - * The scriptPubKey for the output + * A signature of the channel update */ -struct LDKCVec_u8Z TxAddOutput_get_script(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); +void ChannelUpdate_set_signature(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * The scriptPubKey for the output + * The actual channel update */ -void TxAddOutput_set_script(struct LDKTxAddOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); /** - * Constructs a new TxAddOutput given each field + * The actual channel update */ -MUST_USE_RES struct LDKTxAddOutput TxAddOutput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg, uint64_t sats_arg, struct LDKCVec_u8Z script_arg); +void ChannelUpdate_set_contents(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKUnsignedChannelUpdate val); /** - * Creates a copy of the TxAddOutput + * Constructs a new ChannelUpdate given each field */ -struct LDKTxAddOutput TxAddOutput_clone(const struct LDKTxAddOutput *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKECDSASignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); /** - * Generates a non-cryptographic 64-bit hash of the TxAddOutput. + * Creates a copy of the ChannelUpdate */ -uint64_t TxAddOutput_hash(const struct LDKTxAddOutput *NONNULL_PTR o); +struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); /** - * Checks if two TxAddOutputs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Generates a non-cryptographic 64-bit hash of the ChannelUpdate. */ -bool TxAddOutput_eq(const struct LDKTxAddOutput *NONNULL_PTR a, const struct LDKTxAddOutput *NONNULL_PTR b); +uint64_t ChannelUpdate_hash(const struct LDKChannelUpdate *NONNULL_PTR o); /** - * Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL. + * Checks if two ChannelUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void TxRemoveInput_free(struct LDKTxRemoveInput this_obj); +bool ChannelUpdate_eq(const struct LDKChannelUpdate *NONNULL_PTR a, const struct LDKChannelUpdate *NONNULL_PTR b); /** - * The channel ID + * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. */ -struct LDKChannelId TxRemoveInput_get_channel_id(const struct LDKTxRemoveInput *NONNULL_PTR this_ptr); +void QueryChannelRange_free(struct LDKQueryChannelRange this_obj); /** - * The channel ID + * The genesis hash of the blockchain being queried */ -void TxRemoveInput_set_channel_id(struct LDKTxRemoveInput *NONNULL_PTR this_ptr, struct LDKChannelId val); +const uint8_t (*QueryChannelRange_get_chain_hash(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr))[32]; /** - * The serial ID of the input to be removed + * The genesis hash of the blockchain being queried */ -uint64_t TxRemoveInput_get_serial_id(const struct LDKTxRemoveInput *NONNULL_PTR this_ptr); +void QueryChannelRange_set_chain_hash(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The serial ID of the input to be removed + * The height of the first block for the channel UTXOs being queried */ -void TxRemoveInput_set_serial_id(struct LDKTxRemoveInput *NONNULL_PTR this_ptr, uint64_t val); +uint32_t QueryChannelRange_get_first_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); /** - * Constructs a new TxRemoveInput given each field + * The height of the first block for the channel UTXOs being queried */ -MUST_USE_RES struct LDKTxRemoveInput TxRemoveInput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg); +void QueryChannelRange_set_first_blocknum(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a copy of the TxRemoveInput + * The number of blocks to include in the query results */ -struct LDKTxRemoveInput TxRemoveInput_clone(const struct LDKTxRemoveInput *NONNULL_PTR orig); +uint32_t QueryChannelRange_get_number_of_blocks(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the TxRemoveInput. + * The number of blocks to include in the query results */ -uint64_t TxRemoveInput_hash(const struct LDKTxRemoveInput *NONNULL_PTR o); +void QueryChannelRange_set_number_of_blocks(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if two TxRemoveInputs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constructs a new QueryChannelRange given each field */ -bool TxRemoveInput_eq(const struct LDKTxRemoveInput *NONNULL_PTR a, const struct LDKTxRemoveInput *NONNULL_PTR b); +MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); /** - * Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL. + * Creates a copy of the QueryChannelRange */ -void TxRemoveOutput_free(struct LDKTxRemoveOutput this_obj); +struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); /** - * The channel ID + * Generates a non-cryptographic 64-bit hash of the QueryChannelRange. */ -struct LDKChannelId TxRemoveOutput_get_channel_id(const struct LDKTxRemoveOutput *NONNULL_PTR this_ptr); +uint64_t QueryChannelRange_hash(const struct LDKQueryChannelRange *NONNULL_PTR o); /** - * The channel ID + * Checks if two QueryChannelRanges contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void TxRemoveOutput_set_channel_id(struct LDKTxRemoveOutput *NONNULL_PTR this_ptr, struct LDKChannelId val); +bool QueryChannelRange_eq(const struct LDKQueryChannelRange *NONNULL_PTR a, const struct LDKQueryChannelRange *NONNULL_PTR b); /** - * The serial ID of the output to be removed + * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. */ -uint64_t TxRemoveOutput_get_serial_id(const struct LDKTxRemoveOutput *NONNULL_PTR this_ptr); +void ReplyChannelRange_free(struct LDKReplyChannelRange this_obj); /** - * The serial ID of the output to be removed + * The genesis hash of the blockchain being queried */ -void TxRemoveOutput_set_serial_id(struct LDKTxRemoveOutput *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*ReplyChannelRange_get_chain_hash(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new TxRemoveOutput given each field + * The genesis hash of the blockchain being queried */ -MUST_USE_RES struct LDKTxRemoveOutput TxRemoveOutput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg); +void ReplyChannelRange_set_chain_hash(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the TxRemoveOutput + * The height of the first block in the range of the reply */ -struct LDKTxRemoveOutput TxRemoveOutput_clone(const struct LDKTxRemoveOutput *NONNULL_PTR orig); +uint32_t ReplyChannelRange_get_first_blocknum(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the TxRemoveOutput. + * The height of the first block in the range of the reply */ -uint64_t TxRemoveOutput_hash(const struct LDKTxRemoveOutput *NONNULL_PTR o); +void ReplyChannelRange_set_first_blocknum(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if two TxRemoveOutputs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The number of blocks included in the range of the reply */ -bool TxRemoveOutput_eq(const struct LDKTxRemoveOutput *NONNULL_PTR a, const struct LDKTxRemoveOutput *NONNULL_PTR b); +uint32_t ReplyChannelRange_get_number_of_blocks(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL. + * The number of blocks included in the range of the reply */ -void TxComplete_free(struct LDKTxComplete this_obj); +void ReplyChannelRange_set_number_of_blocks(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * The channel ID + * True when this is the final reply for a query */ -struct LDKChannelId TxComplete_get_channel_id(const struct LDKTxComplete *NONNULL_PTR this_ptr); +bool ReplyChannelRange_get_sync_complete(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * The channel ID + * True when this is the final reply for a query */ -void TxComplete_set_channel_id(struct LDKTxComplete *NONNULL_PTR this_ptr, struct LDKChannelId val); +void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val); /** - * Constructs a new TxComplete given each field + * The `short_channel_id`s in the channel range + * + * Returns a copy of the field. */ -MUST_USE_RES struct LDKTxComplete TxComplete_new(struct LDKChannelId channel_id_arg); +struct LDKCVec_u64Z ReplyChannelRange_get_short_channel_ids(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * Creates a copy of the TxComplete + * The `short_channel_id`s in the channel range */ -struct LDKTxComplete TxComplete_clone(const struct LDKTxComplete *NONNULL_PTR orig); +void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Generates a non-cryptographic 64-bit hash of the TxComplete. + * Constructs a new ReplyChannelRange given each field */ -uint64_t TxComplete_hash(const struct LDKTxComplete *NONNULL_PTR o); +MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg); /** - * Checks if two TxCompletes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the ReplyChannelRange */ -bool TxComplete_eq(const struct LDKTxComplete *NONNULL_PTR a, const struct LDKTxComplete *NONNULL_PTR b); +struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); /** - * Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the ReplyChannelRange. */ -void TxSignatures_free(struct LDKTxSignatures this_obj); +uint64_t ReplyChannelRange_hash(const struct LDKReplyChannelRange *NONNULL_PTR o); /** - * The channel ID + * Checks if two ReplyChannelRanges contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKChannelId TxSignatures_get_channel_id(const struct LDKTxSignatures *NONNULL_PTR this_ptr); +bool ReplyChannelRange_eq(const struct LDKReplyChannelRange *NONNULL_PTR a, const struct LDKReplyChannelRange *NONNULL_PTR b); /** - * The channel ID + * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. */ -void TxSignatures_set_channel_id(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKChannelId val); +void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_obj); /** - * The TXID + * The genesis hash of the blockchain being queried */ -const uint8_t (*TxSignatures_get_tx_hash(const struct LDKTxSignatures *NONNULL_PTR this_ptr))[32]; +const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr))[32]; /** - * The TXID + * The genesis hash of the blockchain being queried */ -void TxSignatures_set_tx_hash(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The list of witnesses + * The short_channel_ids that are being queried * * Returns a copy of the field. */ -struct LDKCVec_WitnessZ TxSignatures_get_witnesses(const struct LDKTxSignatures *NONNULL_PTR this_ptr); +struct LDKCVec_u64Z QueryShortChannelIds_get_short_channel_ids(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr); /** - * The list of witnesses + * The short_channel_ids that are being queried */ -void TxSignatures_set_witnesses(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKCVec_WitnessZ val); +void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Optional signature for the shared input -- the previous funding outpoint -- signed by both peers + * Constructs a new QueryShortChannelIds given each field */ -struct LDKCOption_ECDSASignatureZ TxSignatures_get_shared_input_signature(const struct LDKTxSignatures *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); /** - * Optional signature for the shared input -- the previous funding outpoint -- signed by both peers + * Creates a copy of the QueryShortChannelIds */ -void TxSignatures_set_shared_input_signature(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKCOption_ECDSASignatureZ val); +struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); /** - * Constructs a new TxSignatures given each field + * Generates a non-cryptographic 64-bit hash of the QueryShortChannelIds. */ -MUST_USE_RES struct LDKTxSignatures TxSignatures_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes tx_hash_arg, struct LDKCVec_WitnessZ witnesses_arg, struct LDKCOption_ECDSASignatureZ shared_input_signature_arg); +uint64_t QueryShortChannelIds_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR o); /** - * Creates a copy of the TxSignatures + * Checks if two QueryShortChannelIdss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKTxSignatures TxSignatures_clone(const struct LDKTxSignatures *NONNULL_PTR orig); +bool QueryShortChannelIds_eq(const struct LDKQueryShortChannelIds *NONNULL_PTR a, const struct LDKQueryShortChannelIds *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the TxSignatures. + * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. */ -uint64_t TxSignatures_hash(const struct LDKTxSignatures *NONNULL_PTR o); +void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_obj); /** - * Checks if two TxSignaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The genesis hash of the blockchain that was queried */ -bool TxSignatures_eq(const struct LDKTxSignatures *NONNULL_PTR a, const struct LDKTxSignatures *NONNULL_PTR b); +const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL. + * The genesis hash of the blockchain that was queried */ -void TxInitRbf_free(struct LDKTxInitRbf this_obj); +void ReplyShortChannelIdsEnd_set_chain_hash(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The channel ID + * Indicates if the query recipient maintains up-to-date channel + * information for the `chain_hash` */ -struct LDKChannelId TxInitRbf_get_channel_id(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); +bool ReplyShortChannelIdsEnd_get_full_information(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr); /** - * The channel ID + * Indicates if the query recipient maintains up-to-date channel + * information for the `chain_hash` */ -void TxInitRbf_set_channel_id(struct LDKTxInitRbf *NONNULL_PTR this_ptr, struct LDKChannelId val); +void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, bool val); /** - * The locktime of the transaction + * Constructs a new ReplyShortChannelIdsEnd given each field */ -uint32_t TxInitRbf_get_locktime(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); /** - * The locktime of the transaction + * Creates a copy of the ReplyShortChannelIdsEnd */ -void TxInitRbf_set_locktime(struct LDKTxInitRbf *NONNULL_PTR this_ptr, uint32_t val); +struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); /** - * The feerate of the transaction + * Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd. */ -uint32_t TxInitRbf_get_feerate_sat_per_1000_weight(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); +uint64_t ReplyShortChannelIdsEnd_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR o); /** - * The feerate of the transaction + * Checks if two ReplyShortChannelIdsEnds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void TxInitRbf_set_feerate_sat_per_1000_weight(struct LDKTxInitRbf *NONNULL_PTR this_ptr, uint32_t val); +bool ReplyShortChannelIdsEnd_eq(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR a, const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR b); /** - * The number of satoshis the sender will contribute to or, if negative, remove from - * (e.g. splice-out) the funding output of the transaction + * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. */ -struct LDKCOption_i64Z TxInitRbf_get_funding_output_contribution(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); +void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_obj); + +/** + * The genesis hash of the blockchain for channel and node information + */ +const uint8_t (*GossipTimestampFilter_get_chain_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr))[32]; /** - * The number of satoshis the sender will contribute to or, if negative, remove from - * (e.g. splice-out) the funding output of the transaction + * The genesis hash of the blockchain for channel and node information */ -void TxInitRbf_set_funding_output_contribution(struct LDKTxInitRbf *NONNULL_PTR this_ptr, struct LDKCOption_i64Z val); +void GossipTimestampFilter_set_chain_hash(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new TxInitRbf given each field + * The starting unix timestamp */ -MUST_USE_RES struct LDKTxInitRbf TxInitRbf_new(struct LDKChannelId channel_id_arg, uint32_t locktime_arg, uint32_t feerate_sat_per_1000_weight_arg, struct LDKCOption_i64Z funding_output_contribution_arg); +uint32_t GossipTimestampFilter_get_first_timestamp(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); /** - * Creates a copy of the TxInitRbf + * The starting unix timestamp */ -struct LDKTxInitRbf TxInitRbf_clone(const struct LDKTxInitRbf *NONNULL_PTR orig); +void GossipTimestampFilter_set_first_timestamp(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); /** - * Generates a non-cryptographic 64-bit hash of the TxInitRbf. + * The range of information in seconds */ -uint64_t TxInitRbf_hash(const struct LDKTxInitRbf *NONNULL_PTR o); +uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); /** - * Checks if two TxInitRbfs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The range of information in seconds */ -bool TxInitRbf_eq(const struct LDKTxInitRbf *NONNULL_PTR a, const struct LDKTxInitRbf *NONNULL_PTR b); +void GossipTimestampFilter_set_timestamp_range(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL. + * Constructs a new GossipTimestampFilter given each field */ -void TxAckRbf_free(struct LDKTxAckRbf this_obj); +MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); /** - * The channel ID + * Creates a copy of the GossipTimestampFilter */ -struct LDKChannelId TxAckRbf_get_channel_id(const struct LDKTxAckRbf *NONNULL_PTR this_ptr); +struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); /** - * The channel ID + * Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter. */ -void TxAckRbf_set_channel_id(struct LDKTxAckRbf *NONNULL_PTR this_ptr, struct LDKChannelId val); +uint64_t GossipTimestampFilter_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR o); /** - * The number of satoshis the sender will contribute to or, if negative, remove from - * (e.g. splice-out) the funding output of the transaction + * Checks if two GossipTimestampFilters contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCOption_i64Z TxAckRbf_get_funding_output_contribution(const struct LDKTxAckRbf *NONNULL_PTR this_ptr); +bool GossipTimestampFilter_eq(const struct LDKGossipTimestampFilter *NONNULL_PTR a, const struct LDKGossipTimestampFilter *NONNULL_PTR b); /** - * The number of satoshis the sender will contribute to or, if negative, remove from - * (e.g. splice-out) the funding output of the transaction + * Frees any resources used by the ErrorAction */ -void TxAckRbf_set_funding_output_contribution(struct LDKTxAckRbf *NONNULL_PTR this_ptr, struct LDKCOption_i64Z val); +void ErrorAction_free(struct LDKErrorAction this_ptr); /** - * Constructs a new TxAckRbf given each field + * Creates a copy of the ErrorAction */ -MUST_USE_RES struct LDKTxAckRbf TxAckRbf_new(struct LDKChannelId channel_id_arg, struct LDKCOption_i64Z funding_output_contribution_arg); +struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig); /** - * Creates a copy of the TxAckRbf + * Utility method to constructs a new DisconnectPeer-variant ErrorAction */ -struct LDKTxAckRbf TxAckRbf_clone(const struct LDKTxAckRbf *NONNULL_PTR orig); +struct LDKErrorAction ErrorAction_disconnect_peer(struct LDKErrorMessage msg); /** - * Generates a non-cryptographic 64-bit hash of the TxAckRbf. + * Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction */ -uint64_t TxAckRbf_hash(const struct LDKTxAckRbf *NONNULL_PTR o); +struct LDKErrorAction ErrorAction_disconnect_peer_with_warning(struct LDKWarningMessage msg); /** - * Checks if two TxAckRbfs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new IgnoreError-variant ErrorAction */ -bool TxAckRbf_eq(const struct LDKTxAckRbf *NONNULL_PTR a, const struct LDKTxAckRbf *NONNULL_PTR b); +struct LDKErrorAction ErrorAction_ignore_error(void); /** - * Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new IgnoreAndLog-variant ErrorAction */ -void TxAbort_free(struct LDKTxAbort this_obj); +struct LDKErrorAction ErrorAction_ignore_and_log(enum LDKLevel a); /** - * The channel ID + * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction */ -struct LDKChannelId TxAbort_get_channel_id(const struct LDKTxAbort *NONNULL_PTR this_ptr); +struct LDKErrorAction ErrorAction_ignore_duplicate_gossip(void); /** - * The channel ID + * Utility method to constructs a new SendErrorMessage-variant ErrorAction */ -void TxAbort_set_channel_id(struct LDKTxAbort *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKErrorAction ErrorAction_send_error_message(struct LDKErrorMessage msg); /** - * Message data - * - * Returns a copy of the field. + * Utility method to constructs a new SendWarningMessage-variant ErrorAction */ -struct LDKCVec_u8Z TxAbort_get_data(const struct LDKTxAbort *NONNULL_PTR this_ptr); +struct LDKErrorAction ErrorAction_send_warning_message(struct LDKWarningMessage msg, enum LDKLevel log_level); /** - * Message data + * Generates a non-cryptographic 64-bit hash of the ErrorAction. */ -void TxAbort_set_data(struct LDKTxAbort *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +uint64_t ErrorAction_hash(const struct LDKErrorAction *NONNULL_PTR o); /** - * Constructs a new TxAbort given each field + * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKTxAbort TxAbort_new(struct LDKChannelId channel_id_arg, struct LDKCVec_u8Z data_arg); +void LightningError_free(struct LDKLightningError this_obj); /** - * Creates a copy of the TxAbort + * A human-readable message describing the error */ -struct LDKTxAbort TxAbort_clone(const struct LDKTxAbort *NONNULL_PTR orig); +struct LDKStr LightningError_get_err(const struct LDKLightningError *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the TxAbort. + * A human-readable message describing the error */ -uint64_t TxAbort_hash(const struct LDKTxAbort *NONNULL_PTR o); +void LightningError_set_err(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Checks if two TxAborts contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The action which should be taken against the offending peer. */ -bool TxAbort_eq(const struct LDKTxAbort *NONNULL_PTR a, const struct LDKTxAbort *NONNULL_PTR b); +struct LDKErrorAction LightningError_get_action(const struct LDKLightningError *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. + * The action which should be taken against the offending peer. */ -void Shutdown_free(struct LDKShutdown this_obj); +void LightningError_set_action(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKErrorAction val); /** - * The channel ID + * Constructs a new LightningError given each field */ -struct LDKChannelId Shutdown_get_channel_id(const struct LDKShutdown *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKLightningError LightningError_new(struct LDKStr err_arg, struct LDKErrorAction action_arg); /** - * The channel ID + * Creates a copy of the LightningError */ -void Shutdown_set_channel_id(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKLightningError LightningError_clone(const struct LDKLightningError *NONNULL_PTR orig); /** - * The destination of this peer's funds on closing. - * - * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. + * Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z Shutdown_get_scriptpubkey(const struct LDKShutdown *NONNULL_PTR this_ptr); +void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); /** - * The destination of this peer's funds on closing. - * - * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. + * `update_add_htlc` messages which should be sent */ -void Shutdown_set_scriptpubkey(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKCVec_UpdateAddHTLCZ CommitmentUpdate_get_update_add_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Constructs a new Shutdown given each field + * `update_add_htlc` messages which should be sent */ -MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKChannelId channel_id_arg, struct LDKCVec_u8Z scriptpubkey_arg); +void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); /** - * Creates a copy of the Shutdown + * `update_fulfill_htlc` messages which should be sent */ -struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); +struct LDKCVec_UpdateFulfillHTLCZ CommitmentUpdate_get_update_fulfill_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the Shutdown. + * `update_fulfill_htlc` messages which should be sent */ -uint64_t Shutdown_hash(const struct LDKShutdown *NONNULL_PTR o); +void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); /** - * Checks if two Shutdowns contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * `update_fail_htlc` messages which should be sent */ -bool Shutdown_eq(const struct LDKShutdown *NONNULL_PTR a, const struct LDKShutdown *NONNULL_PTR b); +struct LDKCVec_UpdateFailHTLCZ CommitmentUpdate_get_update_fail_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL. + * `update_fail_htlc` messages which should be sent */ -void ClosingSignedFeeRange_free(struct LDKClosingSignedFeeRange this_obj); +void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); /** - * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * `update_fail_malformed_htlc` messages which should be sent */ -uint64_t ClosingSignedFeeRange_get_min_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); +struct LDKCVec_UpdateFailMalformedHTLCZ CommitmentUpdate_get_update_fail_malformed_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * `update_fail_malformed_htlc` messages which should be sent */ -void ClosingSignedFeeRange_set_min_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); +void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); /** - * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * An `update_fee` message which should be sent + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t ClosingSignedFeeRange_get_max_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); +struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * An `update_fee` message which should be sent + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ClosingSignedFeeRange_set_max_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); +void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKUpdateFee val); /** - * Constructs a new ClosingSignedFeeRange given each field + * A `commitment_signed` message which should be sent */ -MUST_USE_RES struct LDKClosingSignedFeeRange ClosingSignedFeeRange_new(uint64_t min_fee_satoshis_arg, uint64_t max_fee_satoshis_arg); +struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Creates a copy of the ClosingSignedFeeRange + * A `commitment_signed` message which should be sent */ -struct LDKClosingSignedFeeRange ClosingSignedFeeRange_clone(const struct LDKClosingSignedFeeRange *NONNULL_PTR orig); +void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCommitmentSigned val); /** - * Generates a non-cryptographic 64-bit hash of the ClosingSignedFeeRange. + * Constructs a new CommitmentUpdate given each field + * + * Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t ClosingSignedFeeRange_hash(const struct LDKClosingSignedFeeRange *NONNULL_PTR o); +MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, struct LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, struct LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, struct LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); /** - * Checks if two ClosingSignedFeeRanges contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the CommitmentUpdate */ -bool ClosingSignedFeeRange_eq(const struct LDKClosingSignedFeeRange *NONNULL_PTR a, const struct LDKClosingSignedFeeRange *NONNULL_PTR b); +struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); /** - * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the CommitmentUpdate. */ -void ClosingSigned_free(struct LDKClosingSigned this_obj); +uint64_t CommitmentUpdate_hash(const struct LDKCommitmentUpdate *NONNULL_PTR o); /** - * The channel ID + * Checks if two CommitmentUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKChannelId ClosingSigned_get_channel_id(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +bool CommitmentUpdate_eq(const struct LDKCommitmentUpdate *NONNULL_PTR a, const struct LDKCommitmentUpdate *NONNULL_PTR b); /** - * The channel ID + * Calls the free function if one is set */ -void ClosingSigned_set_channel_id(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKChannelId val); +void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); /** - * The proposed total fee for the closing transaction + * Calls the free function if one is set */ -uint64_t ClosingSigned_get_fee_satoshis(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); /** - * The proposed total fee for the closing transaction + * Calls the free function if one is set */ -void ClosingSigned_set_fee_satoshis(struct LDKClosingSigned *NONNULL_PTR this_ptr, uint64_t val); +void OnionMessageHandler_free(struct LDKOnionMessageHandler this_ptr); /** - * A signature on the closing transaction + * Frees any resources used by the FinalOnionHopData, if is_owned is set and inner is non-NULL. */ -struct LDKECDSASignature ClosingSigned_get_signature(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +void FinalOnionHopData_free(struct LDKFinalOnionHopData this_obj); /** - * A signature on the closing transaction + * When sending a multi-part payment, this secret is used to identify a payment across HTLCs. + * Because it is generated by the recipient and included in the invoice, it also provides + * proof to the recipient that the payment was sent by someone with the generated invoice. */ -void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +const uint8_t (*FinalOnionHopData_get_payment_secret(const struct LDKFinalOnionHopData *NONNULL_PTR this_ptr))[32]; /** - * The minimum and maximum fees which the sender is willing to accept, provided only by new - * nodes. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * When sending a multi-part payment, this secret is used to identify a payment across HTLCs. + * Because it is generated by the recipient and included in the invoice, it also provides + * proof to the recipient that the payment was sent by someone with the generated invoice. */ -struct LDKClosingSignedFeeRange ClosingSigned_get_fee_range(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +void FinalOnionHopData_set_payment_secret(struct LDKFinalOnionHopData *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The minimum and maximum fees which the sender is willing to accept, provided only by new - * nodes. + * The intended total amount that this payment is for. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Message serialization may panic if this value is more than 21 million Bitcoin. */ -void ClosingSigned_set_fee_range(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKClosingSignedFeeRange val); +uint64_t FinalOnionHopData_get_total_msat(const struct LDKFinalOnionHopData *NONNULL_PTR this_ptr); /** - * Constructs a new ClosingSigned given each field + * The intended total amount that this payment is for. * - * Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Message serialization may panic if this value is more than 21 million Bitcoin. */ -MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKChannelId channel_id_arg, uint64_t fee_satoshis_arg, struct LDKECDSASignature signature_arg, struct LDKClosingSignedFeeRange fee_range_arg); +void FinalOnionHopData_set_total_msat(struct LDKFinalOnionHopData *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the ClosingSigned + * Constructs a new FinalOnionHopData given each field */ -struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); +MUST_USE_RES struct LDKFinalOnionHopData FinalOnionHopData_new(struct LDKThirtyTwoBytes payment_secret_arg, uint64_t total_msat_arg); /** - * Generates a non-cryptographic 64-bit hash of the ClosingSigned. + * Creates a copy of the FinalOnionHopData */ -uint64_t ClosingSigned_hash(const struct LDKClosingSigned *NONNULL_PTR o); +struct LDKFinalOnionHopData FinalOnionHopData_clone(const struct LDKFinalOnionHopData *NONNULL_PTR orig); /** - * Checks if two ClosingSigneds contain equal inner contents. + * Checks if two FinalOnionHopDatas contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool ClosingSigned_eq(const struct LDKClosingSigned *NONNULL_PTR a, const struct LDKClosingSigned *NONNULL_PTR b); - -/** - * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. - */ -void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_obj); - -/** - * The channel ID - */ -struct LDKChannelId UpdateAddHTLC_get_channel_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +bool FinalOnionHopData_eq(const struct LDKFinalOnionHopData *NONNULL_PTR a, const struct LDKFinalOnionHopData *NONNULL_PTR b); /** - * The channel ID + * Frees any resources used by the OnionPacket, if is_owned is set and inner is non-NULL. */ -void UpdateAddHTLC_set_channel_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); +void OnionPacket_free(struct LDKOnionPacket this_obj); /** - * The HTLC ID + * BOLT 4 version number. */ -uint64_t UpdateAddHTLC_get_htlc_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +uint8_t OnionPacket_get_version(const struct LDKOnionPacket *NONNULL_PTR this_ptr); /** - * The HTLC ID + * BOLT 4 version number. */ -void UpdateAddHTLC_set_htlc_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); +void OnionPacket_set_version(struct LDKOnionPacket *NONNULL_PTR this_ptr, uint8_t val); /** - * The HTLC value in milli-satoshi + * In order to ensure we always return an error on onion decode in compliance with [BOLT + * #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to + * deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral + * public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd + * like. + * + * Returns a copy of the field. */ -uint64_t UpdateAddHTLC_get_amount_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +struct LDKCResult_PublicKeySecp256k1ErrorZ OnionPacket_get_public_key(const struct LDKOnionPacket *NONNULL_PTR this_ptr); /** - * The HTLC value in milli-satoshi + * In order to ensure we always return an error on onion decode in compliance with [BOLT + * #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to + * deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral + * public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd + * like. */ -void UpdateAddHTLC_set_amount_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); +void OnionPacket_set_public_key(struct LDKOnionPacket *NONNULL_PTR this_ptr, struct LDKCResult_PublicKeySecp256k1ErrorZ val); /** - * The payment hash, the pre-image of which controls HTLC redemption + * HMAC to verify the integrity of hop_data. */ -const uint8_t (*UpdateAddHTLC_get_payment_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; +const uint8_t (*OnionPacket_get_hmac(const struct LDKOnionPacket *NONNULL_PTR this_ptr))[32]; /** - * The payment hash, the pre-image of which controls HTLC redemption + * HMAC to verify the integrity of hop_data. */ -void UpdateAddHTLC_set_payment_hash(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void OnionPacket_set_hmac(struct LDKOnionPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The expiry height of the HTLC + * Creates a copy of the OnionPacket */ -uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +struct LDKOnionPacket OnionPacket_clone(const struct LDKOnionPacket *NONNULL_PTR orig); /** - * The expiry height of the HTLC + * Generates a non-cryptographic 64-bit hash of the OnionPacket. */ -void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint32_t val); +uint64_t OnionPacket_hash(const struct LDKOnionPacket *NONNULL_PTR o); /** - * The extra fee skimmed by the sender of this message. See - * [`ChannelConfig::accept_underpaying_htlcs`]. - * - * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs + * Checks if two OnionPackets contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCOption_u64Z UpdateAddHTLC_get_skimmed_fee_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +bool OnionPacket_eq(const struct LDKOnionPacket *NONNULL_PTR a, const struct LDKOnionPacket *NONNULL_PTR b); /** - * The extra fee skimmed by the sender of this message. See - * [`ChannelConfig::accept_underpaying_htlcs`]. - * - * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs + * Frees any resources used by the TrampolineOnionPacket, if is_owned is set and inner is non-NULL. */ -void UpdateAddHTLC_set_skimmed_fee_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void TrampolineOnionPacket_free(struct LDKTrampolineOnionPacket this_obj); /** - * The onion routing packet with encrypted data for the next hop. + * Bolt 04 version number */ -struct LDKOnionPacket UpdateAddHTLC_get_onion_routing_packet(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +uint8_t TrampolineOnionPacket_get_version(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr); /** - * The onion routing packet with encrypted data for the next hop. + * Bolt 04 version number */ -void UpdateAddHTLC_set_onion_routing_packet(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKOnionPacket val); +void TrampolineOnionPacket_set_version(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, uint8_t val); /** - * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion - * routing packet and the recipient-provided encrypted payload within. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data */ -struct LDKPublicKey UpdateAddHTLC_get_blinding_point(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +struct LDKPublicKey TrampolineOnionPacket_get_public_key(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr); /** - * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion - * routing packet and the recipient-provided encrypted payload within. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data */ -void UpdateAddHTLC_set_blinding_point(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void TrampolineOnionPacket_set_public_key(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new UpdateAddHTLC given each field + * Encrypted payload for the next hop * - * Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Returns a copy of the field. */ -MUST_USE_RES struct LDKUpdateAddHTLC UpdateAddHTLC_new(struct LDKChannelId channel_id_arg, uint64_t htlc_id_arg, uint64_t amount_msat_arg, struct LDKThirtyTwoBytes payment_hash_arg, uint32_t cltv_expiry_arg, struct LDKCOption_u64Z skimmed_fee_msat_arg, struct LDKOnionPacket onion_routing_packet_arg, struct LDKPublicKey blinding_point_arg); +struct LDKCVec_u8Z TrampolineOnionPacket_get_hop_data(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr); /** - * Creates a copy of the UpdateAddHTLC + * Encrypted payload for the next hop */ -struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); +void TrampolineOnionPacket_set_hop_data(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC. + * HMAC to verify the integrity of hop_data */ -uint64_t UpdateAddHTLC_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR o); +const uint8_t (*TrampolineOnionPacket_get_hmac(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr))[32]; /** - * Checks if two UpdateAddHTLCs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * HMAC to verify the integrity of hop_data */ -bool UpdateAddHTLC_eq(const struct LDKUpdateAddHTLC *NONNULL_PTR a, const struct LDKUpdateAddHTLC *NONNULL_PTR b); +void TrampolineOnionPacket_set_hmac(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL. + * Constructs a new TrampolineOnionPacket given each field */ -void OnionMessage_free(struct LDKOnionMessage this_obj); +MUST_USE_RES struct LDKTrampolineOnionPacket TrampolineOnionPacket_new(uint8_t version_arg, struct LDKPublicKey public_key_arg, struct LDKCVec_u8Z hop_data_arg, struct LDKThirtyTwoBytes hmac_arg); /** - * Used in decrypting the onion packet's payload. + * Creates a copy of the TrampolineOnionPacket */ -struct LDKPublicKey OnionMessage_get_blinding_point(const struct LDKOnionMessage *NONNULL_PTR this_ptr); +struct LDKTrampolineOnionPacket TrampolineOnionPacket_clone(const struct LDKTrampolineOnionPacket *NONNULL_PTR orig); /** - * Used in decrypting the onion packet's payload. + * Generates a non-cryptographic 64-bit hash of the TrampolineOnionPacket. */ -void OnionMessage_set_blinding_point(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t TrampolineOnionPacket_hash(const struct LDKTrampolineOnionPacket *NONNULL_PTR o); /** - * The full onion packet including hop data, pubkey, and hmac + * Checks if two TrampolineOnionPackets contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKPacket OnionMessage_get_onion_routing_packet(const struct LDKOnionMessage *NONNULL_PTR this_ptr); +bool TrampolineOnionPacket_eq(const struct LDKTrampolineOnionPacket *NONNULL_PTR a, const struct LDKTrampolineOnionPacket *NONNULL_PTR b); /** - * The full onion packet including hop data, pubkey, and hmac + * Serialize the TrampolineOnionPacket object into a byte array which can be read by TrampolineOnionPacket_read */ -void OnionMessage_set_onion_routing_packet(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPacket val); +struct LDKCVec_u8Z TrampolineOnionPacket_write(const struct LDKTrampolineOnionPacket *NONNULL_PTR obj); /** - * Constructs a new OnionMessage given each field + * Get the string representation of a DecodeError object */ -MUST_USE_RES struct LDKOnionMessage OnionMessage_new(struct LDKPublicKey blinding_point_arg, struct LDKPacket onion_routing_packet_arg); +struct LDKStr DecodeError_to_str(const struct LDKDecodeError *NONNULL_PTR o); /** - * Creates a copy of the OnionMessage + * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read */ -struct LDKOnionMessage OnionMessage_clone(const struct LDKOnionMessage *NONNULL_PTR orig); +struct LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the OnionMessage. + * Read a AcceptChannel from a byte array, created by AcceptChannel_write */ -uint64_t OnionMessage_hash(const struct LDKOnionMessage *NONNULL_PTR o); +struct LDKCResult_AcceptChannelDecodeErrorZ AcceptChannel_read(struct LDKu8slice ser); /** - * Checks if two OnionMessages contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read */ -bool OnionMessage_eq(const struct LDKOnionMessage *NONNULL_PTR a, const struct LDKOnionMessage *NONNULL_PTR b); +struct LDKCVec_u8Z AcceptChannelV2_write(const struct LDKAcceptChannelV2 *NONNULL_PTR obj); /** - * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. + * Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write */ -void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_obj); +struct LDKCResult_AcceptChannelV2DecodeErrorZ AcceptChannelV2_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the Stfu object into a byte array which can be read by Stfu_read */ -struct LDKChannelId UpdateFulfillHTLC_get_channel_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Stfu_write(const struct LDKStfu *NONNULL_PTR obj); /** - * The channel ID + * Read a Stfu from a byte array, created by Stfu_write */ -void UpdateFulfillHTLC_set_channel_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKCResult_StfuDecodeErrorZ Stfu_read(struct LDKu8slice ser); /** - * The HTLC ID + * Serialize the SpliceInit object into a byte array which can be read by SpliceInit_read */ -uint64_t UpdateFulfillHTLC_get_htlc_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z SpliceInit_write(const struct LDKSpliceInit *NONNULL_PTR obj); /** - * The HTLC ID + * Read a SpliceInit from a byte array, created by SpliceInit_write */ -void UpdateFulfillHTLC_set_htlc_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_SpliceInitDecodeErrorZ SpliceInit_read(struct LDKu8slice ser); /** - * The pre-image of the payment hash, allowing HTLC redemption + * Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read */ -const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z SpliceAck_write(const struct LDKSpliceAck *NONNULL_PTR obj); /** - * The pre-image of the payment hash, allowing HTLC redemption + * Read a SpliceAck from a byte array, created by SpliceAck_write */ -void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_SpliceAckDecodeErrorZ SpliceAck_read(struct LDKu8slice ser); /** - * Constructs a new UpdateFulfillHTLC given each field + * Serialize the SpliceLocked object into a byte array which can be read by SpliceLocked_read */ -MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKChannelId channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); +struct LDKCVec_u8Z SpliceLocked_write(const struct LDKSpliceLocked *NONNULL_PTR obj); /** - * Creates a copy of the UpdateFulfillHTLC + * Read a SpliceLocked from a byte array, created by SpliceLocked_write */ -struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); +struct LDKCResult_SpliceLockedDecodeErrorZ SpliceLocked_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC. + * Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read */ -uint64_t UpdateFulfillHTLC_hash(const struct LDKUpdateFulfillHTLC *NONNULL_PTR o); +struct LDKCVec_u8Z TxAddInput_write(const struct LDKTxAddInput *NONNULL_PTR obj); /** - * Checks if two UpdateFulfillHTLCs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a TxAddInput from a byte array, created by TxAddInput_write */ -bool UpdateFulfillHTLC_eq(const struct LDKUpdateFulfillHTLC *NONNULL_PTR a, const struct LDKUpdateFulfillHTLC *NONNULL_PTR b); +struct LDKCResult_TxAddInputDecodeErrorZ TxAddInput_read(struct LDKu8slice ser); /** - * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. + * Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read */ -void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_obj); +struct LDKCVec_u8Z TxAddOutput_write(const struct LDKTxAddOutput *NONNULL_PTR obj); /** - * The channel ID + * Read a TxAddOutput from a byte array, created by TxAddOutput_write */ -struct LDKChannelId UpdateFailHTLC_get_channel_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); +struct LDKCResult_TxAddOutputDecodeErrorZ TxAddOutput_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read */ -void UpdateFailHTLC_set_channel_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKCVec_u8Z TxRemoveInput_write(const struct LDKTxRemoveInput *NONNULL_PTR obj); /** - * The HTLC ID + * Read a TxRemoveInput from a byte array, created by TxRemoveInput_write */ -uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); +struct LDKCResult_TxRemoveInputDecodeErrorZ TxRemoveInput_read(struct LDKu8slice ser); /** - * The HTLC ID + * Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read */ -void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z TxRemoveOutput_write(const struct LDKTxRemoveOutput *NONNULL_PTR obj); /** - * Creates a copy of the UpdateFailHTLC + * Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write */ -struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); +struct LDKCResult_TxRemoveOutputDecodeErrorZ TxRemoveOutput_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the UpdateFailHTLC. + * Serialize the TxComplete object into a byte array which can be read by TxComplete_read */ -uint64_t UpdateFailHTLC_hash(const struct LDKUpdateFailHTLC *NONNULL_PTR o); +struct LDKCVec_u8Z TxComplete_write(const struct LDKTxComplete *NONNULL_PTR obj); /** - * Checks if two UpdateFailHTLCs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a TxComplete from a byte array, created by TxComplete_write */ -bool UpdateFailHTLC_eq(const struct LDKUpdateFailHTLC *NONNULL_PTR a, const struct LDKUpdateFailHTLC *NONNULL_PTR b); +struct LDKCResult_TxCompleteDecodeErrorZ TxComplete_read(struct LDKu8slice ser); /** - * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. + * Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read */ -void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_obj); +struct LDKCVec_u8Z TxSignatures_write(const struct LDKTxSignatures *NONNULL_PTR obj); /** - * The channel ID + * Read a TxSignatures from a byte array, created by TxSignatures_write */ -struct LDKChannelId UpdateFailMalformedHTLC_get_channel_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); +struct LDKCResult_TxSignaturesDecodeErrorZ TxSignatures_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read */ -void UpdateFailMalformedHTLC_set_channel_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKCVec_u8Z TxInitRbf_write(const struct LDKTxInitRbf *NONNULL_PTR obj); /** - * The HTLC ID + * Read a TxInitRbf from a byte array, created by TxInitRbf_write */ -uint64_t UpdateFailMalformedHTLC_get_htlc_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); +struct LDKCResult_TxInitRbfDecodeErrorZ TxInitRbf_read(struct LDKu8slice ser); /** - * The HTLC ID + * Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read */ -void UpdateFailMalformedHTLC_set_htlc_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z TxAckRbf_write(const struct LDKTxAckRbf *NONNULL_PTR obj); /** - * The failure code + * Read a TxAckRbf from a byte array, created by TxAckRbf_write */ -uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); +struct LDKCResult_TxAckRbfDecodeErrorZ TxAckRbf_read(struct LDKu8slice ser); /** - * The failure code + * Serialize the TxAbort object into a byte array which can be read by TxAbort_read */ -void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint16_t val); +struct LDKCVec_u8Z TxAbort_write(const struct LDKTxAbort *NONNULL_PTR obj); /** - * Creates a copy of the UpdateFailMalformedHTLC + * Read a TxAbort from a byte array, created by TxAbort_write */ -struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); +struct LDKCResult_TxAbortDecodeErrorZ TxAbort_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC. + * Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read */ -uint64_t UpdateFailMalformedHTLC_hash(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR o); +struct LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *NONNULL_PTR obj); /** - * Checks if two UpdateFailMalformedHTLCs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write */ -bool UpdateFailMalformedHTLC_eq(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR a, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR b); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ AnnouncementSignatures_read(struct LDKu8slice ser); /** - * Frees any resources used by the CommitmentSignedBatch, if is_owned is set and inner is non-NULL. + * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read */ -void CommitmentSignedBatch_free(struct LDKCommitmentSignedBatch this_obj); +struct LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *NONNULL_PTR obj); /** - * Batch size N: all N `commitment_signed` messages must be received before being processed + * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write */ -uint16_t CommitmentSignedBatch_get_batch_size(const struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser); /** - * Batch size N: all N `commitment_signed` messages must be received before being processed + * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read */ -void CommitmentSignedBatch_set_batch_size(struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr, uint16_t val); +struct LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *NONNULL_PTR obj); /** - * The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) + * Read a ClosingSigned from a byte array, created by ClosingSigned_write */ -const uint8_t (*CommitmentSignedBatch_get_funding_txid(const struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser); /** - * The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) + * Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read */ -void CommitmentSignedBatch_set_funding_txid(struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z ClosingSignedFeeRange_write(const struct LDKClosingSignedFeeRange *NONNULL_PTR obj); /** - * Constructs a new CommitmentSignedBatch given each field + * Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write */ -MUST_USE_RES struct LDKCommitmentSignedBatch CommitmentSignedBatch_new(uint16_t batch_size_arg, struct LDKThirtyTwoBytes funding_txid_arg); +struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ ClosingSignedFeeRange_read(struct LDKu8slice ser); /** - * Creates a copy of the CommitmentSignedBatch + * Serialize the CommitmentSignedBatch object into a byte array which can be read by CommitmentSignedBatch_read */ -struct LDKCommitmentSignedBatch CommitmentSignedBatch_clone(const struct LDKCommitmentSignedBatch *NONNULL_PTR orig); +struct LDKCVec_u8Z CommitmentSignedBatch_write(const struct LDKCommitmentSignedBatch *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the CommitmentSignedBatch. + * Read a CommitmentSignedBatch from a byte array, created by CommitmentSignedBatch_write */ -uint64_t CommitmentSignedBatch_hash(const struct LDKCommitmentSignedBatch *NONNULL_PTR o); +struct LDKCResult_CommitmentSignedBatchDecodeErrorZ CommitmentSignedBatch_read(struct LDKu8slice ser); /** - * Checks if two CommitmentSignedBatchs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read */ -bool CommitmentSignedBatch_eq(const struct LDKCommitmentSignedBatch *NONNULL_PTR a, const struct LDKCommitmentSignedBatch *NONNULL_PTR b); +struct LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *NONNULL_PTR obj); /** - * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. + * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write */ -void CommitmentSigned_free(struct LDKCommitmentSigned this_obj); +struct LDKCResult_CommitmentSignedDecodeErrorZ CommitmentSigned_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read */ -struct LDKChannelId CommitmentSigned_get_channel_id(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *NONNULL_PTR obj); /** - * The channel ID + * Read a FundingCreated from a byte array, created by FundingCreated_write */ -void CommitmentSigned_set_channel_id(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKCResult_FundingCreatedDecodeErrorZ FundingCreated_read(struct LDKu8slice ser); /** - * A signature on the commitment transaction + * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read */ -struct LDKECDSASignature CommitmentSigned_get_signature(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *NONNULL_PTR obj); /** - * A signature on the commitment transaction + * Read a FundingSigned from a byte array, created by FundingSigned_write */ -void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +struct LDKCResult_FundingSignedDecodeErrorZ FundingSigned_read(struct LDKu8slice ser); /** - * Signatures on the HTLC transactions - * - * Returns a copy of the field. + * Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read */ -struct LDKCVec_ECDSASignatureZ CommitmentSigned_get_htlc_signatures(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ChannelReady_write(const struct LDKChannelReady *NONNULL_PTR obj); /** - * Signatures on the HTLC transactions + * Read a ChannelReady from a byte array, created by ChannelReady_write */ -void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_ECDSASignatureZ val); +struct LDKCResult_ChannelReadyDecodeErrorZ ChannelReady_read(struct LDKu8slice ser); /** - * Optional batch size and other parameters - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the Init object into a byte array which can be read by Init_read */ -struct LDKCommitmentSignedBatch CommitmentSigned_get_batch(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Init_write(const struct LDKInit *NONNULL_PTR obj); /** - * Optional batch size and other parameters - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Read a Init from a byte array, created by Init_write */ -void CommitmentSigned_set_batch(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCommitmentSignedBatch val); +struct LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser); /** - * Constructs a new CommitmentSigned given each field - * - * Note that batch_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read */ -MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKChannelId channel_id_arg, struct LDKECDSASignature signature_arg, struct LDKCVec_ECDSASignatureZ htlc_signatures_arg, struct LDKCommitmentSignedBatch batch_arg); +struct LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *NONNULL_PTR obj); /** - * Creates a copy of the CommitmentSigned + * Read a OpenChannel from a byte array, created by OpenChannel_write */ -struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); +struct LDKCResult_OpenChannelDecodeErrorZ OpenChannel_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the CommitmentSigned. + * Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read */ -uint64_t CommitmentSigned_hash(const struct LDKCommitmentSigned *NONNULL_PTR o); +struct LDKCVec_u8Z OpenChannelV2_write(const struct LDKOpenChannelV2 *NONNULL_PTR obj); /** - * Checks if two CommitmentSigneds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write */ -bool CommitmentSigned_eq(const struct LDKCommitmentSigned *NONNULL_PTR a, const struct LDKCommitmentSigned *NONNULL_PTR b); +struct LDKCResult_OpenChannelV2DecodeErrorZ OpenChannelV2_read(struct LDKu8slice ser); /** - * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. + * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read */ -void RevokeAndACK_free(struct LDKRevokeAndACK this_obj); +struct LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *NONNULL_PTR obj); /** - * The channel ID + * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write */ -struct LDKChannelId RevokeAndACK_get_channel_id(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); +struct LDKCResult_RevokeAndACKDecodeErrorZ RevokeAndACK_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the Shutdown object into a byte array which can be read by Shutdown_read */ -void RevokeAndACK_set_channel_id(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *NONNULL_PTR obj); /** - * The secret corresponding to the per-commitment point + * Read a Shutdown from a byte array, created by Shutdown_write */ -const uint8_t (*RevokeAndACK_get_per_commitment_secret(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_ShutdownDecodeErrorZ Shutdown_read(struct LDKu8slice ser); /** - * The secret corresponding to the per-commitment point + * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read */ -void RevokeAndACK_set_per_commitment_secret(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *NONNULL_PTR obj); /** - * The next sender-broadcast commitment transaction's per-commitment point + * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write */ -struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ UpdateFailHTLC_read(struct LDKu8slice ser); /** - * The next sender-broadcast commitment transaction's per-commitment point + * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read */ -void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR obj); /** - * Constructs a new RevokeAndACK given each field + * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write */ -MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ UpdateFailMalformedHTLC_read(struct LDKu8slice ser); /** - * Creates a copy of the RevokeAndACK + * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read */ -struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); +struct LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the RevokeAndACK. + * Read a UpdateFee from a byte array, created by UpdateFee_write */ -uint64_t RevokeAndACK_hash(const struct LDKRevokeAndACK *NONNULL_PTR o); +struct LDKCResult_UpdateFeeDecodeErrorZ UpdateFee_read(struct LDKu8slice ser); /** - * Checks if two RevokeAndACKs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read */ -bool RevokeAndACK_eq(const struct LDKRevokeAndACK *NONNULL_PTR a, const struct LDKRevokeAndACK *NONNULL_PTR b); +struct LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *NONNULL_PTR obj); /** - * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. + * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write */ -void UpdateFee_free(struct LDKUpdateFee this_obj); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ UpdateFulfillHTLC_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the OnionPacket object into a byte array which can be read by OnionPacket_read */ -struct LDKChannelId UpdateFee_get_channel_id(const struct LDKUpdateFee *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z OnionPacket_write(const struct LDKOnionPacket *NONNULL_PTR obj); /** - * The channel ID + * Read a OnionPacket from a byte array, created by OnionPacket_write */ -void UpdateFee_set_channel_id(struct LDKUpdateFee *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKCResult_OnionPacketDecodeErrorZ OnionPacket_read(struct LDKu8slice ser); /** - * Fee rate per 1000-weight of the transaction + * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read */ -uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PTR obj); /** - * Fee rate per 1000-weight of the transaction + * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write */ -void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); /** - * Constructs a new UpdateFee given each field + * Read a OnionMessage from a byte array, created by OnionMessage_write */ -MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKChannelId channel_id_arg, uint32_t feerate_per_kw_arg); +struct LDKCResult_OnionMessageDecodeErrorZ OnionMessage_read(struct LDKu8slice ser); /** - * Creates a copy of the UpdateFee + * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read */ -struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); +struct LDKCVec_u8Z OnionMessage_write(const struct LDKOnionMessage *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the UpdateFee. + * Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read */ -uint64_t UpdateFee_hash(const struct LDKUpdateFee *NONNULL_PTR o); +struct LDKCVec_u8Z FinalOnionHopData_write(const struct LDKFinalOnionHopData *NONNULL_PTR obj); /** - * Checks if two UpdateFees contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write */ -bool UpdateFee_eq(const struct LDKUpdateFee *NONNULL_PTR a, const struct LDKUpdateFee *NONNULL_PTR b); +struct LDKCResult_FinalOnionHopDataDecodeErrorZ FinalOnionHopData_read(struct LDKu8slice ser); /** - * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. + * Serialize the Ping object into a byte array which can be read by Ping_read */ -void ChannelReestablish_free(struct LDKChannelReestablish this_obj); +struct LDKCVec_u8Z Ping_write(const struct LDKPing *NONNULL_PTR obj); /** - * The channel ID + * Read a Ping from a byte array, created by Ping_write */ -struct LDKChannelId ChannelReestablish_get_channel_id(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +struct LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the Pong object into a byte array which can be read by Pong_read */ -void ChannelReestablish_set_channel_id(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKCVec_u8Z Pong_write(const struct LDKPong *NONNULL_PTR obj); /** - * The next commitment number for the sender + * Read a Pong from a byte array, created by Pong_write */ -uint64_t ChannelReestablish_get_next_local_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +struct LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser); /** - * The next commitment number for the sender + * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read */ -void ChannelReestablish_set_next_local_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR obj); /** - * The next commitment number for the recipient + * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write */ -uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser); /** - * The next commitment number for the recipient + * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read */ -void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *NONNULL_PTR obj); /** - * Proof that the sender knows the per-commitment secret of a specific commitment transaction - * belonging to the recipient + * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write */ -const uint8_t (*ChannelReestablish_get_your_last_per_commitment_secret(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_ChannelAnnouncementDecodeErrorZ ChannelAnnouncement_read(struct LDKu8slice ser); /** - * Proof that the sender knows the per-commitment secret of a specific commitment transaction - * belonging to the recipient + * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read */ -void ChannelReestablish_set_your_last_per_commitment_secret(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *NONNULL_PTR obj); /** - * The sender's per-commitment point for their current commitment transaction + * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write */ -struct LDKPublicKey ChannelReestablish_get_my_current_per_commitment_point(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser); /** - * The sender's per-commitment point for their current commitment transaction + * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read */ -void ChannelReestablish_set_my_current_per_commitment_point(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *NONNULL_PTR obj); /** - * The next funding transaction ID + * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write */ -struct LDKCOption_ThirtyTwoBytesZ ChannelReestablish_get_next_funding_txid(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelUpdateDecodeErrorZ ChannelUpdate_read(struct LDKu8slice ser); /** - * The next funding transaction ID + * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read */ -void ChannelReestablish_set_next_funding_txid(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); +struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR obj); /** - * Constructs a new ChannelReestablish given each field + * Read a ErrorMessage from a byte array, created by ErrorMessage_write */ -MUST_USE_RES struct LDKChannelReestablish ChannelReestablish_new(struct LDKChannelId channel_id_arg, uint64_t next_local_commitment_number_arg, uint64_t next_remote_commitment_number_arg, struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg, struct LDKCOption_ThirtyTwoBytesZ next_funding_txid_arg); +struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); /** - * Creates a copy of the ChannelReestablish + * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read */ -struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); +struct LDKCVec_u8Z WarningMessage_write(const struct LDKWarningMessage *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the ChannelReestablish. + * Read a WarningMessage from a byte array, created by WarningMessage_write */ -uint64_t ChannelReestablish_hash(const struct LDKChannelReestablish *NONNULL_PTR o); +struct LDKCResult_WarningMessageDecodeErrorZ WarningMessage_read(struct LDKu8slice ser); /** - * Checks if two ChannelReestablishs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read */ -bool ChannelReestablish_eq(const struct LDKChannelReestablish *NONNULL_PTR a, const struct LDKChannelReestablish *NONNULL_PTR b); +struct LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR obj); /** - * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. + * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write */ -void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_obj); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read */ -struct LDKChannelId AnnouncementSignatures_get_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *NONNULL_PTR obj); /** - * The channel ID + * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write */ -void AnnouncementSignatures_set_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKChannelId val); +struct LDKCResult_NodeAnnouncementDecodeErrorZ NodeAnnouncement_read(struct LDKu8slice ser); /** - * The short channel ID + * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write */ -uint64_t AnnouncementSignatures_get_short_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser); /** - * The short channel ID + * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read */ -void AnnouncementSignatures_set_short_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); /** - * A signature by the node key + * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read */ -struct LDKECDSASignature AnnouncementSignatures_get_node_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); /** - * A signature by the node key + * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write */ -void AnnouncementSignatures_set_node_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); /** - * A signature by the funding key + * Calculates the overflow safe ending block height for the query. + * + * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`. */ -struct LDKECDSASignature AnnouncementSignatures_get_bitcoin_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); /** - * A signature by the funding key + * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read */ -void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); /** - * Constructs a new AnnouncementSignatures given each field + * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write */ -MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKChannelId channel_id_arg, uint64_t short_channel_id_arg, struct LDKECDSASignature node_signature_arg, struct LDKECDSASignature bitcoin_signature_arg); +struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); /** - * Creates a copy of the AnnouncementSignatures + * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write */ -struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the AnnouncementSignatures. + * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read */ -uint64_t AnnouncementSignatures_hash(const struct LDKAnnouncementSignatures *NONNULL_PTR o); +struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); /** - * Checks if two AnnouncementSignaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read */ -bool AnnouncementSignatures_eq(const struct LDKAnnouncementSignatures *NONNULL_PTR a, const struct LDKAnnouncementSignatures *NONNULL_PTR b); +struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); /** - * Frees any resources used by the SocketAddress + * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write */ -void SocketAddress_free(struct LDKSocketAddress this_ptr); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); /** - * Creates a copy of the SocketAddress + * Calls the free function if one is set */ -struct LDKSocketAddress SocketAddress_clone(const struct LDKSocketAddress *NONNULL_PTR orig); +void CustomMessageHandler_free(struct LDKCustomMessageHandler this_ptr); /** - * Utility method to constructs a new TcpIpV4-variant SocketAddress + * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. */ -struct LDKSocketAddress SocketAddress_tcp_ip_v4(struct LDKFourBytes addr, uint16_t port); +void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); /** - * Utility method to constructs a new TcpIpV6-variant SocketAddress + * Constructs a new IgnoringMessageHandler given each field */ -struct LDKSocketAddress SocketAddress_tcp_ip_v6(struct LDKSixteenBytes addr, uint16_t port); +MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); /** - * Utility method to constructs a new OnionV2-variant SocketAddress + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -struct LDKSocketAddress SocketAddress_onion_v2(struct LDKTwelveBytes a); +struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OnionV3-variant SocketAddress + * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is */ -struct LDKSocketAddress SocketAddress_onion_v3(struct LDKThirtyTwoBytes ed25519_pubkey, uint16_t checksum, uint8_t version, uint16_t port); +struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Hostname-variant SocketAddress + * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is */ -struct LDKSocketAddress SocketAddress_hostname(struct LDKHostname hostname, uint16_t port); +struct LDKOnionMessageHandler IgnoringMessageHandler_as_OnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the SocketAddress. + * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is */ -uint64_t SocketAddress_hash(const struct LDKSocketAddress *NONNULL_PTR o); +struct LDKOffersMessageHandler IgnoringMessageHandler_as_OffersMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Checks if two SocketAddresss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is */ -bool SocketAddress_eq(const struct LDKSocketAddress *NONNULL_PTR a, const struct LDKSocketAddress *NONNULL_PTR b); +struct LDKAsyncPaymentsMessageHandler IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read + * Constructs a new DNSResolverMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned DNSResolverMessageHandler must be freed before this_arg is */ -struct LDKCVec_u8Z SocketAddress_write(const struct LDKSocketAddress *NONNULL_PTR obj); +struct LDKDNSResolverMessageHandler IgnoringMessageHandler_as_DNSResolverMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Read a SocketAddress from a byte array, created by SocketAddress_write + * Constructs a new CustomOnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomOnionMessageHandler must be freed before this_arg is */ -struct LDKCResult_SocketAddressDecodeErrorZ SocketAddress_read(struct LDKu8slice ser); +struct LDKCustomOnionMessageHandler IgnoringMessageHandler_as_CustomOnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Creates a copy of the SocketAddressParseError + * Constructs a new CustomMessageReader which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomMessageReader must be freed before this_arg is */ -enum LDKSocketAddressParseError SocketAddressParseError_clone(const enum LDKSocketAddressParseError *NONNULL_PTR orig); +struct LDKCustomMessageReader IgnoringMessageHandler_as_CustomMessageReader(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError + * Constructs a new CustomMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomMessageHandler must be freed before this_arg is */ -enum LDKSocketAddressParseError SocketAddressParseError_socket_addr_parse(void); +struct LDKCustomMessageHandler IgnoringMessageHandler_as_CustomMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidInput-variant SocketAddressParseError + * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. */ -enum LDKSocketAddressParseError SocketAddressParseError_invalid_input(void); +void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); /** - * Utility method to constructs a new InvalidPort-variant SocketAddressParseError + * Constructs a new ErroringMessageHandler */ -enum LDKSocketAddressParseError SocketAddressParseError_invalid_port(void); +MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); /** - * Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -enum LDKSocketAddressParseError SocketAddressParseError_invalid_onion_v3(void); +struct LDKMessageSendEventsProvider ErroringMessageHandler_as_MessageSendEventsProvider(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the SocketAddressParseError. + * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is */ -uint64_t SocketAddressParseError_hash(const enum LDKSocketAddressParseError *NONNULL_PTR o); +struct LDKChannelMessageHandler ErroringMessageHandler_as_ChannelMessageHandler(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); /** - * Checks if two SocketAddressParseErrors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. */ -bool SocketAddressParseError_eq(const enum LDKSocketAddressParseError *NONNULL_PTR a, const enum LDKSocketAddressParseError *NONNULL_PTR b); +void MessageHandler_free(struct LDKMessageHandler this_obj); /** - * Get the string representation of a SocketAddressParseError object + * A message handler which handles messages specific to channels. Usually this is just a + * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -struct LDKStr SocketAddressParseError_to_str(const enum LDKSocketAddressParseError *NONNULL_PTR o); +const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`]. + * A message handler which handles messages specific to channels. Usually this is just a + * [`ChannelManager`] object or an [`ErroringMessageHandler`]. * - * The host part must end with \".onion\". + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -struct LDKCResult_SocketAddressSocketAddressParseErrorZ parse_onion_address(struct LDKStr host, uint16_t port); +void MessageHandler_set_chan_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKChannelMessageHandler val); /** - * Get the string representation of a SocketAddress object + * A message handler which handles messages updating our knowledge of the network channel + * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. + * + * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync */ -struct LDKStr SocketAddress_to_str(const struct LDKSocketAddress *NONNULL_PTR o); +const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Read a SocketAddress object from a string + * A message handler which handles messages updating our knowledge of the network channel + * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. + * + * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync */ -struct LDKCResult_SocketAddressSocketAddressParseErrorZ SocketAddress_from_str(struct LDKStr s); +void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); /** - * Frees any resources used by the UnsignedGossipMessage + * A message handler which handles onion messages. This should generally be an + * [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. + * + * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger */ -void UnsignedGossipMessage_free(struct LDKUnsignedGossipMessage this_ptr); +const struct LDKOnionMessageHandler *MessageHandler_get_onion_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Creates a copy of the UnsignedGossipMessage + * A message handler which handles onion messages. This should generally be an + * [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. + * + * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_clone(const struct LDKUnsignedGossipMessage *NONNULL_PTR orig); +void MessageHandler_set_onion_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKOnionMessageHandler val); /** - * Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage + * A message handler which handles custom messages. The only LDK-provided implementation is + * [`IgnoringMessageHandler`]. */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_announcement(struct LDKUnsignedChannelAnnouncement a); +const struct LDKCustomMessageHandler *MessageHandler_get_custom_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage + * A message handler which handles custom messages. The only LDK-provided implementation is + * [`IgnoringMessageHandler`]. */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_update(struct LDKUnsignedChannelUpdate a); +void MessageHandler_set_custom_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKCustomMessageHandler val); /** - * Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage + * Constructs a new MessageHandler given each field */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_node_announcement(struct LDKUnsignedNodeAnnouncement a); +MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg, struct LDKOnionMessageHandler onion_message_handler_arg, struct LDKCustomMessageHandler custom_message_handler_arg); /** - * Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read + * Creates a copy of a SocketDescriptor */ -struct LDKCVec_u8Z UnsignedGossipMessage_write(const struct LDKUnsignedGossipMessage *NONNULL_PTR obj); +struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *NONNULL_PTR orig); /** - * Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. + * Calls the free function if one is set */ -void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj); +void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); /** - * The advertised features + * Frees any resources used by the PeerDetails, if is_owned is set and inner is non-NULL. */ -struct LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +void PeerDetails_free(struct LDKPeerDetails this_obj); /** - * The advertised features + * The node id of the peer. + * + * For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter + * passed in to [`PeerManager::new_outbound_connection`]. */ -void UnsignedNodeAnnouncement_set_features(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +struct LDKPublicKey PeerDetails_get_counterparty_node_id(const struct LDKPeerDetails *NONNULL_PTR this_ptr); /** - * A strictly monotonic announcement counter, with gaps allowed + * The node id of the peer. + * + * For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter + * passed in to [`PeerManager::new_outbound_connection`]. */ -uint32_t UnsignedNodeAnnouncement_get_timestamp(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +void PeerDetails_set_counterparty_node_id(struct LDKPeerDetails *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * A strictly monotonic announcement counter, with gaps allowed + * The socket address the peer provided in the initial handshake. + * + * Will only be `Some` if an address had been previously provided to + * [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`]. + * + * Returns a copy of the field. */ -void UnsignedNodeAnnouncement_set_timestamp(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCOption_SocketAddressZ PeerDetails_get_socket_address(const struct LDKPeerDetails *NONNULL_PTR this_ptr); /** - * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back - * to this node). + * The socket address the peer provided in the initial handshake. + * + * Will only be `Some` if an address had been previously provided to + * [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`]. */ -struct LDKNodeId UnsignedNodeAnnouncement_get_node_id(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +void PeerDetails_set_socket_address(struct LDKPeerDetails *NONNULL_PTR this_ptr, struct LDKCOption_SocketAddressZ val); /** - * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back - * to this node). + * The features the peer provided in the initial handshake. */ -void UnsignedNodeAnnouncement_set_node_id(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +struct LDKInitFeatures PeerDetails_get_init_features(const struct LDKPeerDetails *NONNULL_PTR this_ptr); /** - * An RGB color for UI purposes + * The features the peer provided in the initial handshake. */ -const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[3]; +void PeerDetails_set_init_features(struct LDKPeerDetails *NONNULL_PTR this_ptr, struct LDKInitFeatures val); /** - * An RGB color for UI purposes + * Indicates the direction of the peer connection. + * + * Will be `true` for inbound connections, and `false` for outbound connections. */ -void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThreeBytes val); +bool PeerDetails_get_is_inbound_connection(const struct LDKPeerDetails *NONNULL_PTR this_ptr); /** - * An alias, for UI purposes. + * Indicates the direction of the peer connection. * - * This should be sanitized before use. There is no guarantee of uniqueness. + * Will be `true` for inbound connections, and `false` for outbound connections. */ -struct LDKNodeAlias UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +void PeerDetails_set_is_inbound_connection(struct LDKPeerDetails *NONNULL_PTR this_ptr, bool val); /** - * An alias, for UI purposes. - * - * This should be sanitized before use. There is no guarantee of uniqueness. + * Constructs a new PeerDetails given each field */ -void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeAlias val); +MUST_USE_RES struct LDKPeerDetails PeerDetails_new(struct LDKPublicKey counterparty_node_id_arg, struct LDKCOption_SocketAddressZ socket_address_arg, struct LDKInitFeatures init_features_arg, bool is_inbound_connection_arg); /** - * List of addresses on which this node is reachable - * - * Returns a copy of the field. + * Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_SocketAddressZ UnsignedNodeAnnouncement_get_addresses(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +void PeerHandleError_free(struct LDKPeerHandleError this_obj); /** - * List of addresses on which this node is reachable + * Constructs a new PeerHandleError given each field */ -void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_SocketAddressZ val); +MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(void); /** - * Excess address data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol. - * - * Returns a copy of the field. + * Creates a copy of the PeerHandleError */ -struct LDKCVec_u8Z UnsignedNodeAnnouncement_get_excess_address_data(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError *NONNULL_PTR orig); /** - * Excess address data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol. + * Get the string representation of a PeerHandleError object */ -void UnsignedNodeAnnouncement_set_excess_address_data(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKStr PeerHandleError_to_str(const struct LDKPeerHandleError *NONNULL_PTR o); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. - * - * Returns a copy of the field. + * Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z UnsignedNodeAnnouncement_get_excess_data(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +void PeerManager_free(struct LDKPeerManager this_obj); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. + * Constructs a new `PeerManager` with the given message handlers. * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * `ephemeral_random_data` is used to derive per-connection ephemeral keys and must be + * cryptographically secure random bytes. + * + * `current_time` is used as an always-increasing counter that survives across restarts and is + * incremented irregularly internally. In general it is best to simply use the current UNIX + * timestamp, however if it is not available a persistent counter that increases once per + * minute should suffice. */ -void UnsignedNodeAnnouncement_set_excess_data(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, uint32_t current_time, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKNodeSigner node_signer); /** - * Constructs a new UnsignedNodeAnnouncement given each field + * Returns a list of [`PeerDetails`] for connected peers that have completed the initial + * handshake. */ -MUST_USE_RES struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_new(struct LDKNodeFeatures features_arg, uint32_t timestamp_arg, struct LDKNodeId node_id_arg, struct LDKThreeBytes rgb_arg, struct LDKNodeAlias alias_arg, struct LDKCVec_SocketAddressZ addresses_arg, struct LDKCVec_u8Z excess_address_data_arg, struct LDKCVec_u8Z excess_data_arg); +MUST_USE_RES struct LDKCVec_PeerDetailsZ PeerManager_list_peers(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Creates a copy of the UnsignedNodeAnnouncement + * Returns the [`PeerDetails`] of a connected peer that has completed the initial handshake. + * + * Will return `None` if the peer is unknown or it hasn't completed the initial handshake. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); +MUST_USE_RES struct LDKPeerDetails PeerManager_peer_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id); /** - * Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement. + * Indicates a new outbound connection has been established to a node with the given `node_id` + * and an optional remote network address. + * + * The remote network address adds the option to report a remote IP address back to a connecting + * peer using the init message. + * The user should pass the remote network address of the host they are connected to. + * + * If an `Err` is returned here you must disconnect the connection immediately. + * + * Returns a small number of bytes to send to the remote node (currently always 50). + * + * Panics if descriptor is duplicative with some other descriptor which has not yet been + * [`socket_disconnected`]. + * + * [`socket_disconnected`]: PeerManager::socket_disconnected */ -uint64_t UnsignedNodeAnnouncement_hash(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR o); +MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor, struct LDKCOption_SocketAddressZ remote_network_address); /** - * Checks if two UnsignedNodeAnnouncements contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Indicates a new inbound connection has been established to a node with an optional remote + * network address. + * + * The remote network address adds the option to report a remote IP address back to a connecting + * peer using the init message. + * The user should pass the remote network address of the host they are connected to. + * + * May refuse the connection by returning an Err, but will never write bytes to the remote end + * (outbound connector always speaks first). If an `Err` is returned here you must disconnect + * the connection immediately. + * + * Panics if descriptor is duplicative with some other descriptor which has not yet been + * [`socket_disconnected`]. + * + * [`socket_disconnected`]: PeerManager::socket_disconnected */ -bool UnsignedNodeAnnouncement_eq(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR a, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR b); +MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor, struct LDKCOption_SocketAddressZ remote_network_address); /** - * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. + * Indicates that there is room to write data to the given socket descriptor. + * + * May return an Err to indicate that the connection should be closed. + * + * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before + * returning. Thus, be very careful with reentrancy issues! The invariants around calling + * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be + * ready to call [`write_buffer_space_avail`] again if a write call generated here isn't + * sufficient! + * + * [`send_data`]: SocketDescriptor::send_data + * [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail */ -void NodeAnnouncement_free(struct LDKNodeAnnouncement this_obj); +MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR descriptor); /** - * The signature by the node key + * Indicates that data was read from the given socket descriptor. + * + * May return an Err to indicate that the connection should be closed. + * + * Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity. + * Thus, however, you should call [`process_events`] after any `read_event` to generate + * [`send_data`] calls to handle responses. + * + * If `Ok(true)` is returned, further read_events should not be triggered until a + * [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the + * send buffer). + * + * In order to avoid processing too many messages at once per peer, `data` should be on the + * order of 4KiB. + * + * [`send_data`]: SocketDescriptor::send_data + * [`process_events`]: PeerManager::process_events */ -struct LDKECDSASignature NodeAnnouncement_get_signature(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR peer_descriptor, struct LDKu8slice data); /** - * The signature by the node key + * Checks for any events generated by our handlers and processes them. Includes sending most + * response messages as well as messages generated by calls to handler functions directly (eg + * functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]). + * + * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy + * issues! + * + * This should be called any time we may have messages to send. It is automatically called by + * [`lightning-net-tokio`] after processing incoming messages, and by + * [`lightning-background-processor`] when channel state has changed. Therefore, If you are not + * using both [`lightning-net-tokio`] and [`lightning-background-processor`], you may need to call + * this function manually to prevent messages from being delayed. + * + * Note that if there are any other calls to this function waiting on lock(s) this may return + * without doing any work. All available events that need handling will be handled before the + * other calls return. + * + * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards + * [`send_data`]: SocketDescriptor::send_data */ -void NodeAnnouncement_set_signature(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void PeerManager_process_events(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * The actual content of the announcement + * Indicates that the given socket descriptor's connection is now closed. */ -struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); +void PeerManager_socket_disconnected(const struct LDKPeerManager *NONNULL_PTR this_arg, const struct LDKSocketDescriptor *NONNULL_PTR descriptor); /** - * The actual content of the announcement + * Disconnect a peer given its node id. + * + * If a peer is connected, this will call [`disconnect_socket`] on the descriptor for the + * peer. Thus, be very careful about reentrancy issues. + * + * [`disconnect_socket`]: SocketDescriptor::disconnect_socket */ -void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedNodeAnnouncement val); +void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id); /** - * Constructs a new NodeAnnouncement given each field + * Disconnects all currently-connected peers. This is useful on platforms where there may be + * an indication that TCP sockets have stalled even if we weren't around to time them out + * using regular ping/pongs. */ -MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKECDSASignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); +void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Creates a copy of the NodeAnnouncement + * Send pings to each peer and disconnect those which did not respond to the last round of + * pings. + * + * This may be called on any timescale you want, however, roughly once every ten seconds is + * preferred. The call rate determines both how often we send a ping to our peers and how much + * time they have to respond before we disconnect them. + * + * May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy + * issues! + * + * [`send_data`]: SocketDescriptor::send_data */ -struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); +void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the NodeAnnouncement. + * Generates a signed node_announcement from the given arguments, sending it to all connected + * peers. Note that peers will likely ignore this message unless we have at least one public + * channel which has at least six confirmations on-chain. + * + * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this + * node to humans. They carry no in-protocol meaning. + * + * `addresses` represent the set (possibly empty) of socket addresses on which this node + * accepts incoming connections. These will be included in the node_announcement, publicly + * tying these addresses together and to this node. If you wish to preserve user privacy, + * addresses should likely contain only Tor Onion addresses. + * + * Panics if `addresses` is absurdly large (more than 100). + * + * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events */ -uint64_t NodeAnnouncement_hash(const struct LDKNodeAnnouncement *NONNULL_PTR o); +void PeerManager_broadcast_node_announcement(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_SocketAddressZ addresses); /** - * Checks if two NodeAnnouncements contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Gets the weight for an HTLC-Success transaction. */ -bool NodeAnnouncement_eq(const struct LDKNodeAnnouncement *NONNULL_PTR a, const struct LDKNodeAnnouncement *NONNULL_PTR b); +uint64_t htlc_success_tx_weight(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); /** - * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. + * Gets the weight for an HTLC-Timeout transaction. */ -void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_obj); +uint64_t htlc_timeout_tx_weight(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); /** - * The advertised channel features + * Creates a copy of the HTLCClaim */ -struct LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +enum LDKHTLCClaim HTLCClaim_clone(const enum LDKHTLCClaim *NONNULL_PTR orig); /** - * The advertised channel features + * Utility method to constructs a new OfferedTimeout-variant HTLCClaim */ -void UnsignedChannelAnnouncement_set_features(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +enum LDKHTLCClaim HTLCClaim_offered_timeout(void); /** - * The genesis hash of the blockchain where the channel is to be opened + * Utility method to constructs a new OfferedPreimage-variant HTLCClaim */ -const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr))[32]; +enum LDKHTLCClaim HTLCClaim_offered_preimage(void); /** - * The genesis hash of the blockchain where the channel is to be opened + * Utility method to constructs a new AcceptedTimeout-variant HTLCClaim */ -void UnsignedChannelAnnouncement_set_chain_hash(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +enum LDKHTLCClaim HTLCClaim_accepted_timeout(void); /** - * The short channel ID + * Utility method to constructs a new AcceptedPreimage-variant HTLCClaim */ -uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +enum LDKHTLCClaim HTLCClaim_accepted_preimage(void); /** - * The short channel ID + * Utility method to constructs a new Revocation-variant HTLCClaim */ -void UnsignedChannelAnnouncement_set_short_channel_id(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, uint64_t val); +enum LDKHTLCClaim HTLCClaim_revocation(void); /** - * One of the two `node_id`s which are endpoints of this channel + * Checks if two HTLCClaims contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +bool HTLCClaim_eq(const enum LDKHTLCClaim *NONNULL_PTR a, const enum LDKHTLCClaim *NONNULL_PTR b); /** - * One of the two `node_id`s which are endpoints of this channel + * Check if a given input witness attempts to claim a HTLC. */ -void UnsignedChannelAnnouncement_set_node_id_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +MUST_USE_RES struct LDKCOption_HTLCClaimZ HTLCClaim_from_witness(struct LDKWitness witness); /** - * The other of the two `node_id`s which are endpoints of this channel + * Build the commitment secret from the seed and the commitment number */ -struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); /** - * The other of the two `node_id`s which are endpoints of this channel + * Build a closing transaction */ -void UnsignedChannelAnnouncement_set_node_id_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +struct LDKTransaction build_closing_transaction(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); /** - * The funding key for the first node + * Frees any resources used by the CounterpartyCommitmentSecrets, if is_owned is set and inner is non-NULL. */ -struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +void CounterpartyCommitmentSecrets_free(struct LDKCounterpartyCommitmentSecrets this_obj); /** - * The funding key for the first node + * Creates a copy of the CounterpartyCommitmentSecrets */ -void UnsignedChannelAnnouncement_set_bitcoin_key_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_clone(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR orig); /** - * The funding key for the second node + * Creates a new empty `CounterpartyCommitmentSecrets` structure. */ -struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_new(void); /** - * The funding key for the second node + * Returns the minimum index of all stored secrets. Note that indexes start + * at 1 << 48 and get decremented by one for each new secret. */ -void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +MUST_USE_RES uint64_t CounterpartyCommitmentSecrets_get_min_seen_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. - * - * Returns a copy of the field. + * Inserts the `secret` at `idx`. Returns `Ok(())` if the secret + * was generated in accordance with BOLT 3 and is consistent with previous secrets. */ -struct LDKCVec_u8Z UnsignedChannelAnnouncement_get_excess_data(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ CounterpartyCommitmentSecrets_provide_secret(struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx, struct LDKThirtyTwoBytes secret); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. + * Returns the secret at `idx`. + * Returns `None` if `idx` is < [`CounterpartyCommitmentSecrets::get_min_seen_secret`]. * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void UnsignedChannelAnnouncement_set_excess_data(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +MUST_USE_RES struct LDKThirtyTwoBytes CounterpartyCommitmentSecrets_get_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx); /** - * Constructs a new UnsignedChannelAnnouncement given each field + * Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read */ -MUST_USE_RES struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_new(struct LDKChannelFeatures features_arg, struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, struct LDKNodeId node_id_1_arg, struct LDKNodeId node_id_2_arg, struct LDKNodeId bitcoin_key_1_arg, struct LDKNodeId bitcoin_key_2_arg, struct LDKCVec_u8Z excess_data_arg); +struct LDKCVec_u8Z CounterpartyCommitmentSecrets_write(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR obj); /** - * Creates a copy of the UnsignedChannelAnnouncement + * Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write */ -struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CounterpartyCommitmentSecrets_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement. + * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) + * from the base secret and the per_commitment_point. */ -uint64_t UnsignedChannelAnnouncement_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR o); +struct LDKSecretKey derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); /** - * Checks if two UnsignedChannelAnnouncements contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Derives a per-commitment-transaction revocation key from its constituent parts. + * + * Only the cheating participant owns a valid witness to propagate a revoked + * commitment transaction, thus per_commitment_secret always come from cheater + * and revocation_base_secret always come from punisher, which is the broadcaster + * of the transaction spending with this key knowledge. */ -bool UnsignedChannelAnnouncement_eq(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR a, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR b); +struct LDKSecretKey derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]); /** - * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. + * Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. */ -void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_obj); +void TxCreationKeys_free(struct LDKTxCreationKeys this_obj); /** - * Authentication of the announcement by the first public node + * The broadcaster's per-commitment public key which was used to derive the other keys. */ -struct LDKECDSASignature ChannelAnnouncement_get_node_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKPublicKey TxCreationKeys_get_per_commitment_point(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Authentication of the announcement by the first public node + * The broadcaster's per-commitment public key which was used to derive the other keys. */ -void ChannelAnnouncement_set_node_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void TxCreationKeys_set_per_commitment_point(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Authentication of the announcement by the second public node + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ -struct LDKECDSASignature ChannelAnnouncement_get_node_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKRevocationKey TxCreationKeys_get_revocation_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Authentication of the announcement by the second public node + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ -void ChannelAnnouncement_set_node_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void TxCreationKeys_set_revocation_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKRevocationKey val); /** - * Proof of funding UTXO ownership by the first public node + * Broadcaster's HTLC Key */ -struct LDKECDSASignature ChannelAnnouncement_get_bitcoin_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKHtlcKey TxCreationKeys_get_broadcaster_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Proof of funding UTXO ownership by the first public node + * Broadcaster's HTLC Key */ -void ChannelAnnouncement_set_bitcoin_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void TxCreationKeys_set_broadcaster_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKHtlcKey val); /** - * Proof of funding UTXO ownership by the second public node + * Countersignatory's HTLC Key */ -struct LDKECDSASignature ChannelAnnouncement_get_bitcoin_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKHtlcKey TxCreationKeys_get_countersignatory_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Proof of funding UTXO ownership by the second public node + * Countersignatory's HTLC Key */ -void ChannelAnnouncement_set_bitcoin_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void TxCreationKeys_set_countersignatory_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKHtlcKey val); /** - * The actual announcement + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKDelayedPaymentKey TxCreationKeys_get_broadcaster_delayed_payment_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * The actual announcement + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedChannelAnnouncement val); +void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKDelayedPaymentKey val); /** - * Constructs a new ChannelAnnouncement given each field + * Constructs a new TxCreationKeys given each field */ -MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKECDSASignature node_signature_1_arg, struct LDKECDSASignature node_signature_2_arg, struct LDKECDSASignature bitcoin_signature_1_arg, struct LDKECDSASignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKRevocationKey revocation_key_arg, struct LDKHtlcKey broadcaster_htlc_key_arg, struct LDKHtlcKey countersignatory_htlc_key_arg, struct LDKDelayedPaymentKey broadcaster_delayed_payment_key_arg); /** - * Creates a copy of the ChannelAnnouncement + * Checks if two TxCreationKeyss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); +bool TxCreationKeys_eq(const struct LDKTxCreationKeys *NONNULL_PTR a, const struct LDKTxCreationKeys *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement. + * Creates a copy of the TxCreationKeys */ -uint64_t ChannelAnnouncement_hash(const struct LDKChannelAnnouncement *NONNULL_PTR o); +struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *NONNULL_PTR orig); /** - * Checks if two ChannelAnnouncements contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read */ -bool ChannelAnnouncement_eq(const struct LDKChannelAnnouncement *NONNULL_PTR a, const struct LDKChannelAnnouncement *NONNULL_PTR b); +struct LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *NONNULL_PTR obj); /** - * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. + * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write */ -void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_obj); +struct LDKCResult_TxCreationKeysDecodeErrorZ TxCreationKeys_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain where the channel is to be opened + * Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. */ -const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr))[32]; +void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_obj); /** - * The genesis hash of the blockchain where the channel is to be opened + * The public key which is used to sign all commitment transactions, as it appears in the + * on-chain channel lock-in 2-of-2 multisig output. */ -void UnsignedChannelUpdate_set_chain_hash(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * The short channel ID + * The public key which is used to sign all commitment transactions, as it appears in the + * on-chain channel lock-in 2-of-2 multisig output. */ -uint64_t UnsignedChannelUpdate_get_short_channel_id(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The short channel ID + * The base point which is used (with [`RevocationKey::from_basepoint`]) to derive per-commitment + * revocation keys. This is combined with the per-commitment-secret generated by the + * counterparty to create a secret which the counterparty can reveal to revoke previous + * states. */ -void UnsignedChannelUpdate_set_short_channel_id(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +struct LDKRevocationBasepoint ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * A strictly monotonic announcement counter, with gaps allowed, specific to this channel + * The base point which is used (with [`RevocationKey::from_basepoint`]) to derive per-commitment + * revocation keys. This is combined with the per-commitment-secret generated by the + * counterparty to create a secret which the counterparty can reveal to revoke previous + * states. */ -uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void ChannelPublicKeys_set_revocation_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKRevocationBasepoint val); /** - * A strictly monotonic announcement counter, with gaps allowed, specific to this channel + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ -void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +struct LDKPublicKey ChannelPublicKeys_get_payment_point(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Flags pertaining to this message. + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ -uint8_t UnsignedChannelUpdate_get_message_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void ChannelPublicKeys_set_payment_point(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Flags pertaining to this message. + * The base point which is used (with derive_public_key) to derive a per-commitment payment + * public key which receives non-HTLC-encumbered funds which are only available for spending + * after some delay (or can be claimed via the revocation path). */ -void UnsignedChannelUpdate_set_message_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); +struct LDKDelayedPaymentBasepoint ChannelPublicKeys_get_delayed_payment_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Flags pertaining to the channel, including to which direction in the channel this update - * applies and whether the direction is currently able to forward HTLCs. + * The base point which is used (with derive_public_key) to derive a per-commitment payment + * public key which receives non-HTLC-encumbered funds which are only available for spending + * after some delay (or can be claimed via the revocation path). */ -uint8_t UnsignedChannelUpdate_get_channel_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void ChannelPublicKeys_set_delayed_payment_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKDelayedPaymentBasepoint val); /** - * Flags pertaining to the channel, including to which direction in the channel this update - * applies and whether the direction is currently able to forward HTLCs. + * The base point which is used (with derive_public_key) to derive a per-commitment public key + * which is used to encumber HTLC-in-flight outputs. */ -void UnsignedChannelUpdate_set_channel_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); +struct LDKHtlcBasepoint ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * The number of blocks such that if: - * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` - * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines - * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a - * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, - * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before - * forwarding. Note that the HTLC sender is the one who originally sets this value when - * constructing the route. + * The base point which is used (with derive_public_key) to derive a per-commitment public key + * which is used to encumber HTLC-in-flight outputs. */ -uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKHtlcBasepoint val); /** - * The number of blocks such that if: - * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` - * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines - * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a - * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, - * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before - * forwarding. Note that the HTLC sender is the one who originally sets this value when - * constructing the route. + * Constructs a new ChannelPublicKeys given each field */ -void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKRevocationBasepoint revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKDelayedPaymentBasepoint delayed_payment_basepoint_arg, struct LDKHtlcBasepoint htlc_basepoint_arg); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Creates a copy of the ChannelPublicKeys */ -uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Generates a non-cryptographic 64-bit hash of the ChannelPublicKeys. */ -void UnsignedChannelUpdate_set_htlc_minimum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +uint64_t ChannelPublicKeys_hash(const struct LDKChannelPublicKeys *NONNULL_PTR o); /** - * The maximum HTLC value incoming to sender, in milli-satoshi. - * - * This used to be optional. + * Checks if two ChannelPublicKeyss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint64_t UnsignedChannelUpdate_get_htlc_maximum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +bool ChannelPublicKeys_eq(const struct LDKChannelPublicKeys *NONNULL_PTR a, const struct LDKChannelPublicKeys *NONNULL_PTR b); /** - * The maximum HTLC value incoming to sender, in milli-satoshi. - * - * This used to be optional. + * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read */ -void UnsignedChannelUpdate_set_htlc_maximum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *NONNULL_PTR obj); /** - * The base HTLC fee charged by sender, in milli-satoshi + * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write */ -uint32_t UnsignedChannelUpdate_get_fee_base_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelPublicKeysDecodeErrorZ ChannelPublicKeys_read(struct LDKu8slice ser); /** - * The base HTLC fee charged by sender, in milli-satoshi + * Create per-state keys from channel base points and the per-commitment point. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. */ -void UnsignedChannelUpdate_set_fee_base_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_derive_new(struct LDKPublicKey per_commitment_point, const struct LDKDelayedPaymentBasepoint *NONNULL_PTR broadcaster_delayed_payment_base, const struct LDKHtlcBasepoint *NONNULL_PTR broadcaster_htlc_base, const struct LDKRevocationBasepoint *NONNULL_PTR countersignatory_revocation_base, const struct LDKHtlcBasepoint *NONNULL_PTR countersignatory_htlc_base); /** - * The amount to fee multiplier, in micro-satoshi + * Generate per-state keys from channel static keys. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. */ -uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_from_channel_static_keys(struct LDKPublicKey per_commitment_point, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); /** - * The amount to fee multiplier, in micro-satoshi + * A script either spendable by the revocation + * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. + * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. */ -void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z get_revokeable_redeemscript(const struct LDKRevocationKey *NONNULL_PTR revocation_key, uint16_t contest_delay, const struct LDKDelayedPaymentKey *NONNULL_PTR broadcaster_delayed_payment_key); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. - * - * Returns a copy of the field. + * Returns the script for the counterparty's output on a holder's commitment transaction based on + * the channel type. */ -struct LDKCVec_u8Z UnsignedChannelUpdate_get_excess_data(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z get_counterparty_payment_script(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, struct LDKPublicKey payment_key); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. */ -void UnsignedChannelUpdate_set_excess_data(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_obj); /** - * Constructs a new UnsignedChannelUpdate given each field + * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). + * Note that this is not the same as whether it is ountbound *from us*. To determine that you + * need to compare this value to whether the commitment transaction in question is that of + * the counterparty or our own. */ -MUST_USE_RES struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_new(struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, uint32_t timestamp_arg, uint8_t message_flags_arg, uint8_t channel_flags_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, struct LDKCVec_u8Z excess_data_arg); +bool HTLCOutputInCommitment_get_offered(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Creates a copy of the UnsignedChannelUpdate + * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). + * Note that this is not the same as whether it is ountbound *from us*. To determine that you + * need to compare this value to whether the commitment transaction in question is that of + * the counterparty or our own. */ -struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); +void HTLCOutputInCommitment_set_offered(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, bool val); /** - * Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate. + * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is + * this divided by 1000. */ -uint64_t UnsignedChannelUpdate_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR o); +uint64_t HTLCOutputInCommitment_get_amount_msat(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Checks if two UnsignedChannelUpdates contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is + * this divided by 1000. */ -bool UnsignedChannelUpdate_eq(const struct LDKUnsignedChannelUpdate *NONNULL_PTR a, const struct LDKUnsignedChannelUpdate *NONNULL_PTR b); +void HTLCOutputInCommitment_set_amount_msat(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. + * The CLTV lock-time at which this HTLC expires. */ -void ChannelUpdate_free(struct LDKChannelUpdate this_obj); +uint32_t HTLCOutputInCommitment_get_cltv_expiry(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * A signature of the channel update + * The CLTV lock-time at which this HTLC expires. */ -struct LDKECDSASignature ChannelUpdate_get_signature(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); +void HTLCOutputInCommitment_set_cltv_expiry(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint32_t val); /** - * A signature of the channel update + * The hash of the preimage which unlocks this HTLC. */ -void ChannelUpdate_set_signature(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr))[32]; /** - * The actual channel update + * The hash of the preimage which unlocks this HTLC. */ -struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); +void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The actual channel update + * The position within the commitment transactions' outputs. This may be None if the value is + * below the dust limit (in which case no output appears in the commitment transaction and the + * value is spent to additional transaction fees). */ -void ChannelUpdate_set_contents(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKUnsignedChannelUpdate val); +struct LDKCOption_u32Z HTLCOutputInCommitment_get_transaction_output_index(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Constructs a new ChannelUpdate given each field + * The position within the commitment transactions' outputs. This may be None if the value is + * below the dust limit (in which case no output appears in the commitment transaction and the + * value is spent to additional transaction fees). */ -MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKECDSASignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); +void HTLCOutputInCommitment_set_transaction_output_index(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); /** - * Creates a copy of the ChannelUpdate + * Constructs a new HTLCOutputInCommitment given each field */ -struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); +MUST_USE_RES struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_new(bool offered_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_u32Z transaction_output_index_arg); /** - * Generates a non-cryptographic 64-bit hash of the ChannelUpdate. + * Creates a copy of the HTLCOutputInCommitment */ -uint64_t ChannelUpdate_hash(const struct LDKChannelUpdate *NONNULL_PTR o); +struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); /** - * Checks if two ChannelUpdates contain equal inner contents. + * Checks if two HTLCOutputInCommitments contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool ChannelUpdate_eq(const struct LDKChannelUpdate *NONNULL_PTR a, const struct LDKChannelUpdate *NONNULL_PTR b); +bool HTLCOutputInCommitment_eq(const struct LDKHTLCOutputInCommitment *NONNULL_PTR a, const struct LDKHTLCOutputInCommitment *NONNULL_PTR b); /** - * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. + * Converts HTLC's value with millisatoshi precision into [bitcoin::Amount] with satoshi precision. + * Typically this conversion is needed when transitioning from LN into base-layer Bitcoin, + * e. g. in commitment transactions. */ -void QueryChannelRange_free(struct LDKQueryChannelRange this_obj); +MUST_USE_RES uint64_t HTLCOutputInCommitment_to_bitcoin_amount(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_arg); /** - * The genesis hash of the blockchain being queried + * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read */ -const uint8_t (*QueryChannelRange_get_chain_hash(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *NONNULL_PTR obj); /** - * The genesis hash of the blockchain being queried + * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write */ -void QueryChannelRange_set_chain_hash(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read(struct LDKu8slice ser); /** - * The height of the first block for the channel UTXOs being queried + * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc + * does not need to have its previous_output_index filled. */ -uint32_t QueryChannelRange_get_first_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, const struct LDKTxCreationKeys *NONNULL_PTR keys); /** - * The height of the first block for the channel UTXOs being queried + * Gets the redeemscript for a funding output from the two funding public keys. + * Note that the order of funding public keys does not matter. */ -void QueryChannelRange_set_first_blocknum(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); /** - * The number of blocks to include in the query results + * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC + * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the + * transaction which needs signing, and can be used to construct an HTLC transaction which is + * broadcastable given a counterparty HTLC signature. + * + * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the + * commitment transaction). */ -uint32_t QueryChannelRange_get_number_of_blocks(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); +struct LDKTransaction build_htlc_transaction(const uint8_t (*commitment_txid)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, const struct LDKDelayedPaymentKey *NONNULL_PTR broadcaster_delayed_payment_key, const struct LDKRevocationKey *NONNULL_PTR revocation_key); /** - * The number of blocks to include in the query results + * Returns the witness required to satisfy and spend a HTLC input. */ -void QueryChannelRange_set_number_of_blocks(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); +struct LDKWitness build_htlc_input_witness(struct LDKECDSASignature local_sig, struct LDKECDSASignature remote_sig, struct LDKCOption_ThirtyTwoBytesZ preimage, struct LDKu8slice redeem_script, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); /** - * Constructs a new QueryChannelRange given each field + * Gets the witnessScript for the to_remote output when anchors are enabled. */ -MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); +struct LDKCVec_u8Z get_to_countersignatory_with_anchors_redeemscript(struct LDKPublicKey payment_point); /** - * Creates a copy of the QueryChannelRange + * Gets the witnessScript for an anchor output from the funding public key. + * The witness in the spending input must be: + * + * After 16 blocks of confirmation, an alternative satisfying witness could be: + * <> + * (empty vector required to satisfy compliance with MINIMALIF-standard rule) */ -struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); +struct LDKCVec_u8Z get_anchor_redeemscript(struct LDKPublicKey funding_pubkey); /** - * Generates a non-cryptographic 64-bit hash of the QueryChannelRange. + * Returns the witness required to satisfy and spend an anchor input. */ -uint64_t QueryChannelRange_hash(const struct LDKQueryChannelRange *NONNULL_PTR o); +struct LDKWitness build_anchor_input_witness(struct LDKPublicKey funding_key, struct LDKECDSASignature funding_sig); /** - * Checks if two QueryChannelRanges contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -bool QueryChannelRange_eq(const struct LDKQueryChannelRange *NONNULL_PTR a, const struct LDKQueryChannelRange *NONNULL_PTR b); +void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_obj); /** - * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. + * Holder public keys */ -void ReplyChannelRange_free(struct LDKReplyChannelRange this_obj); +struct LDKChannelPublicKeys ChannelTransactionParameters_get_holder_pubkeys(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain being queried + * Holder public keys */ -const uint8_t (*ReplyChannelRange_get_chain_hash(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr))[32]; +void ChannelTransactionParameters_set_holder_pubkeys(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); /** - * The genesis hash of the blockchain being queried + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions */ -void ReplyChannelRange_set_chain_hash(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +uint16_t ChannelTransactionParameters_get_holder_selected_contest_delay(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * The height of the first block in the range of the reply + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions */ -uint32_t ReplyChannelRange_get_first_blocknum(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_holder_selected_contest_delay(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); /** - * The height of the first block in the range of the reply + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. */ -void ReplyChannelRange_set_first_blocknum(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); +bool ChannelTransactionParameters_get_is_outbound_from_holder(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * The number of blocks included in the range of the reply + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. */ -uint32_t ReplyChannelRange_get_number_of_blocks(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_is_outbound_from_holder(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, bool val); /** - * The number of blocks included in the range of the reply + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ReplyChannelRange_set_number_of_blocks(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * True when this is the final reply for a query + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -bool ReplyChannelRange_get_sync_complete(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKCounterpartyChannelTransactionParameters val); /** - * True when this is the final reply for a query + * The late-bound funding outpoint + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val); +struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * The `short_channel_id`s in the channel range + * The late-bound funding outpoint * - * Returns a copy of the field. + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u64Z ReplyChannelRange_get_short_channel_ids(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * The `short_channel_id`s in the channel range + * This channel's type, as negotiated during channel open. For old objects where this field + * wasn't serialized, it will default to static_remote_key at deserialization. */ -void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +struct LDKChannelTypeFeatures ChannelTransactionParameters_get_channel_type_features(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Constructs a new ReplyChannelRange given each field + * This channel's type, as negotiated during channel open. For old objects where this field + * wasn't serialized, it will default to static_remote_key at deserialization. */ -MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg); +void ChannelTransactionParameters_set_channel_type_features(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * Creates a copy of the ReplyChannelRange + * Constructs a new ChannelTransactionParameters given each field + * + * Note that counterparty_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that funding_outpoint_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg, struct LDKChannelTypeFeatures channel_type_features_arg); /** - * Generates a non-cryptographic 64-bit hash of the ReplyChannelRange. + * Creates a copy of the ChannelTransactionParameters */ -uint64_t ReplyChannelRange_hash(const struct LDKReplyChannelRange *NONNULL_PTR o); +struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); /** - * Checks if two ReplyChannelRanges contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the ChannelTransactionParameters. + */ +uint64_t ChannelTransactionParameters_hash(const struct LDKChannelTransactionParameters *NONNULL_PTR o); + +/** + * Checks if two ChannelTransactionParameterss contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool ReplyChannelRange_eq(const struct LDKReplyChannelRange *NONNULL_PTR a, const struct LDKReplyChannelRange *NONNULL_PTR b); +bool ChannelTransactionParameters_eq(const struct LDKChannelTransactionParameters *NONNULL_PTR a, const struct LDKChannelTransactionParameters *NONNULL_PTR b); /** - * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. + * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_obj); +void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_obj); /** - * The genesis hash of the blockchain being queried + * Counter-party public keys */ -const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr))[32]; +struct LDKChannelPublicKeys CounterpartyChannelTransactionParameters_get_pubkeys(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain being queried + * Counter-party public keys */ -void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void CounterpartyChannelTransactionParameters_set_pubkeys(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); /** - * The short_channel_ids that are being queried - * - * Returns a copy of the field. + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -struct LDKCVec_u64Z QueryShortChannelIds_get_short_channel_ids(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr); +uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * The short_channel_ids that are being queried + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); /** - * Constructs a new QueryShortChannelIds given each field + * Constructs a new CounterpartyChannelTransactionParameters given each field */ -MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); +MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); /** - * Creates a copy of the QueryShortChannelIds + * Creates a copy of the CounterpartyChannelTransactionParameters */ -struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); +struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the QueryShortChannelIds. + * Generates a non-cryptographic 64-bit hash of the CounterpartyChannelTransactionParameters. */ -uint64_t QueryShortChannelIds_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR o); +uint64_t CounterpartyChannelTransactionParameters_hash(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR o); /** - * Checks if two QueryShortChannelIdss contain equal inner contents. + * Checks if two CounterpartyChannelTransactionParameterss contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool QueryShortChannelIds_eq(const struct LDKQueryShortChannelIds *NONNULL_PTR a, const struct LDKQueryShortChannelIds *NONNULL_PTR b); - -/** - * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. - */ -void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_obj); - -/** - * The genesis hash of the blockchain that was queried - */ -const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr))[32]; +bool CounterpartyChannelTransactionParameters_eq(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR a, const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR b); /** - * The genesis hash of the blockchain that was queried + * Whether the late bound parameters are populated. */ -void ReplyShortChannelIdsEnd_set_chain_hash(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES bool ChannelTransactionParameters_is_populated(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Indicates if the query recipient maintains up-to-date channel - * information for the `chain_hash` + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the holder is the broadcaster. + * + * self.is_populated() must be true before calling this function. */ -bool ReplyShortChannelIdsEnd_get_full_information(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_holder_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Indicates if the query recipient maintains up-to-date channel - * information for the `chain_hash` + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the counterparty is the broadcaster. + * + * self.is_populated() must be true before calling this function. */ -void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Constructs a new ReplyShortChannelIdsEnd given each field + * Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read */ -MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); +struct LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR obj); /** - * Creates a copy of the ReplyShortChannelIdsEnd + * Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write */ -struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd. + * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read */ -uint64_t ReplyShortChannelIdsEnd_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR o); +struct LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *NONNULL_PTR obj); /** - * Checks if two ReplyShortChannelIdsEnds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write */ -bool ReplyShortChannelIdsEnd_eq(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR a, const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR b); +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ ChannelTransactionParameters_read(struct LDKu8slice ser); /** - * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. + * Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_obj); +void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_obj); /** - * The genesis hash of the blockchain for channel and node information + * Get the channel pubkeys for the broadcaster */ -const uint8_t (*GossipTimestampFilter_get_chain_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_broadcaster_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * The genesis hash of the blockchain for channel and node information + * Get the channel pubkeys for the countersignatory */ -void GossipTimestampFilter_set_chain_hash(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_countersignatory_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * The starting unix timestamp + * Get the contest delay applicable to the transactions. + * Note that the contest delay was selected by the countersignatory. */ -uint32_t GossipTimestampFilter_get_first_timestamp(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); +MUST_USE_RES uint16_t DirectedChannelTransactionParameters_contest_delay(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * The starting unix timestamp + * Whether the channel is outbound from the broadcaster. + * + * The boolean representing the side that initiated the channel is + * an input to the commitment number obscure factor computation. */ -void GossipTimestampFilter_set_first_timestamp(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * The range of information in seconds + * The funding outpoint */ -uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * The range of information in seconds + * Whether to use anchors for this channel */ -void GossipTimestampFilter_set_timestamp_range(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKChannelTypeFeatures DirectedChannelTransactionParameters_channel_type_features(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Constructs a new GossipTimestampFilter given each field + * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); +void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_obj); /** - * Creates a copy of the GossipTimestampFilter + * Our counterparty's signature for the transaction */ -struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); +struct LDKECDSASignature HolderCommitmentTransaction_get_counterparty_sig(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter. + * Our counterparty's signature for the transaction */ -uint64_t GossipTimestampFilter_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR o); +void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * Checks if two GossipTimestampFilters contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * All non-dust counterparty HTLC signatures, in the order they appear in the transaction + * + * Returns a copy of the field. */ -bool GossipTimestampFilter_eq(const struct LDKGossipTimestampFilter *NONNULL_PTR a, const struct LDKGossipTimestampFilter *NONNULL_PTR b); +struct LDKCVec_ECDSASignatureZ HolderCommitmentTransaction_get_counterparty_htlc_sigs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ErrorAction + * All non-dust counterparty HTLC signatures, in the order they appear in the transaction */ -void ErrorAction_free(struct LDKErrorAction this_ptr); +void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_ECDSASignatureZ val); /** - * Creates a copy of the ErrorAction + * Creates a copy of the HolderCommitmentTransaction */ -struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig); +struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *NONNULL_PTR orig); /** - * Utility method to constructs a new DisconnectPeer-variant ErrorAction + * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read */ -struct LDKErrorAction ErrorAction_disconnect_peer(struct LDKErrorMessage msg); +struct LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *NONNULL_PTR obj); /** - * Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction + * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write */ -struct LDKErrorAction ErrorAction_disconnect_peer_with_warning(struct LDKWarningMessage msg); +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransaction_read(struct LDKu8slice ser); /** - * Utility method to constructs a new IgnoreError-variant ErrorAction + * Create a new holder transaction with the given counterparty signatures. + * The funding keys are used to figure out which signature should go first when building the transaction for broadcast. */ -struct LDKErrorAction ErrorAction_ignore_error(void); +MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKECDSASignature counterparty_sig, struct LDKCVec_ECDSASignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); /** - * Utility method to constructs a new IgnoreAndLog-variant ErrorAction + * Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKErrorAction ErrorAction_ignore_and_log(enum LDKLevel a); +void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_obj); /** - * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction + * The commitment transaction */ -struct LDKErrorAction ErrorAction_ignore_duplicate_gossip(void); +struct LDKTransaction BuiltCommitmentTransaction_get_transaction(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new SendErrorMessage-variant ErrorAction + * The commitment transaction */ -struct LDKErrorAction ErrorAction_send_error_message(struct LDKErrorMessage msg); +void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKTransaction val); /** - * Utility method to constructs a new SendWarningMessage-variant ErrorAction + * The txid for the commitment transaction. + * + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. */ -struct LDKErrorAction ErrorAction_send_warning_message(struct LDKWarningMessage msg, enum LDKLevel log_level); +const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32]; /** - * Generates a non-cryptographic 64-bit hash of the ErrorAction. + * The txid for the commitment transaction. + * + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. */ -uint64_t ErrorAction_hash(const struct LDKErrorAction *NONNULL_PTR o); +void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. + * Constructs a new BuiltCommitmentTransaction given each field */ -void LightningError_free(struct LDKLightningError this_obj); +MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); /** - * A human-readable message describing the error + * Creates a copy of the BuiltCommitmentTransaction */ -struct LDKStr LightningError_get_err(const struct LDKLightningError *NONNULL_PTR this_ptr); +struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig); /** - * A human-readable message describing the error + * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read */ -void LightningError_set_err(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKStr val); +struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj); /** - * The action which should be taken against the offending peer. + * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write */ -struct LDKErrorAction LightningError_get_action(const struct LDKLightningError *NONNULL_PTR this_ptr); +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser); /** - * The action which should be taken against the offending peer. + * Get the SIGHASH_ALL sighash value of the transaction. + * + * This can be used to verify a signature. */ -void LightningError_set_action(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKErrorAction val); +MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Constructs a new LightningError given each field + * Signs the counterparty's commitment transaction. */ -MUST_USE_RES struct LDKLightningError LightningError_new(struct LDKStr err_arg, struct LDKErrorAction action_arg); +MUST_USE_RES struct LDKECDSASignature BuiltCommitmentTransaction_sign_counterparty_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Creates a copy of the LightningError + * Signs the holder commitment transaction because we are about to broadcast it. */ -struct LDKLightningError LightningError_clone(const struct LDKLightningError *NONNULL_PTR orig); +MUST_USE_RES struct LDKECDSASignature BuiltCommitmentTransaction_sign_holder_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis, const struct LDKEntropySource *NONNULL_PTR entropy_source); /** - * Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ClosingTransaction, if is_owned is set and inner is non-NULL. */ -void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); +void ClosingTransaction_free(struct LDKClosingTransaction this_obj); /** - * `update_add_htlc` messages which should be sent + * Creates a copy of the ClosingTransaction */ -struct LDKCVec_UpdateAddHTLCZ CommitmentUpdate_get_update_add_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig); /** - * `update_add_htlc` messages which should be sent + * Generates a non-cryptographic 64-bit hash of the ClosingTransaction. */ -void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); +uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o); /** - * `update_fulfill_htlc` messages which should be sent + * Checks if two ClosingTransactions contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCVec_UpdateFulfillHTLCZ CommitmentUpdate_get_update_fulfill_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +bool ClosingTransaction_eq(const struct LDKClosingTransaction *NONNULL_PTR a, const struct LDKClosingTransaction *NONNULL_PTR b); /** - * `update_fulfill_htlc` messages which should be sent + * Construct an object of the class */ -void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); +MUST_USE_RES struct LDKClosingTransaction ClosingTransaction_new(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); /** - * `update_fail_htlc` messages which should be sent + * Trust our pre-built transaction. + * + * Applies a wrapper which allows access to the transaction. + * + * This should only be used if you fully trust the builder of this object. It should not + * be used by an external signer - instead use the verify function. */ -struct LDKCVec_UpdateFailHTLCZ CommitmentUpdate_get_update_fail_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTrustedClosingTransaction ClosingTransaction_trust(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * `update_fail_htlc` messages which should be sent + * Verify our pre-built transaction. + * + * Applies a wrapper which allows access to the transaction. + * + * An external validating signer must call this method before signing + * or using the built transaction. */ -void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); +MUST_USE_RES struct LDKCResult_TrustedClosingTransactionNoneZ ClosingTransaction_verify(const struct LDKClosingTransaction *NONNULL_PTR this_arg, struct LDKOutPoint funding_outpoint); /** - * `update_fail_malformed_htlc` messages which should be sent + * The value to be sent to the holder, or zero if the output will be omitted */ -struct LDKCVec_UpdateFailMalformedHTLCZ CommitmentUpdate_get_update_fail_malformed_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES uint64_t ClosingTransaction_to_holder_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * `update_fail_malformed_htlc` messages which should be sent + * The value to be sent to the counterparty, or zero if the output will be omitted */ -void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); +MUST_USE_RES uint64_t ClosingTransaction_to_counterparty_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * An `update_fee` message which should be sent - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The destination of the holder's output */ -struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKu8slice ClosingTransaction_to_holder_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * An `update_fee` message which should be sent - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The destination of the counterparty's output */ -void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKUpdateFee val); +MUST_USE_RES struct LDKu8slice ClosingTransaction_to_counterparty_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * A `commitment_signed` message which should be sent + * Frees any resources used by the TrustedClosingTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +void TrustedClosingTransaction_free(struct LDKTrustedClosingTransaction this_obj); /** - * A `commitment_signed` message which should be sent + * The pre-built Bitcoin commitment transaction */ -void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCommitmentSigned val); +MUST_USE_RES struct LDKTransaction TrustedClosingTransaction_built_transaction(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg); /** - * Constructs a new CommitmentUpdate given each field + * Get the SIGHASH_ALL sighash value of the transaction. * - * Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * This can be used to verify a signature. */ -MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, struct LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, struct LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, struct LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); +MUST_USE_RES struct LDKThirtyTwoBytes TrustedClosingTransaction_get_sighash_all(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Creates a copy of the CommitmentUpdate + * Sign a transaction, either because we are counter-signing the counterparty's transaction or + * because we are about to broadcast a holder transaction. */ -struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); +MUST_USE_RES struct LDKECDSASignature TrustedClosingTransaction_sign(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Generates a non-cryptographic 64-bit hash of the CommitmentUpdate. + * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. */ -uint64_t CommitmentUpdate_hash(const struct LDKCommitmentUpdate *NONNULL_PTR o); +void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); /** - * Checks if two CommitmentUpdates contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the CommitmentTransaction */ -bool CommitmentUpdate_eq(const struct LDKCommitmentUpdate *NONNULL_PTR a, const struct LDKCommitmentUpdate *NONNULL_PTR b); +struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); /** - * Calls the free function if one is set + * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read */ -void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); +struct LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *NONNULL_PTR obj); /** - * Calls the free function if one is set + * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write */ -void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); +struct LDKCResult_CommitmentTransactionDecodeErrorZ CommitmentTransaction_read(struct LDKu8slice ser); /** - * Calls the free function if one is set + * The backwards-counting commitment number */ -void OnionMessageHandler_free(struct LDKOnionMessageHandler this_ptr); +MUST_USE_RES uint64_t CommitmentTransaction_commitment_number(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Frees any resources used by the FinalOnionHopData, if is_owned is set and inner is non-NULL. + * The per commitment point used by the broadcaster. */ -void FinalOnionHopData_free(struct LDKFinalOnionHopData this_obj); +MUST_USE_RES struct LDKPublicKey CommitmentTransaction_per_commitment_point(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * When sending a multi-part payment, this secret is used to identify a payment across HTLCs. - * Because it is generated by the recipient and included in the invoice, it also provides - * proof to the recipient that the payment was sent by someone with the generated invoice. + * The value to be sent to the broadcaster */ -const uint8_t (*FinalOnionHopData_get_payment_secret(const struct LDKFinalOnionHopData *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES uint64_t CommitmentTransaction_to_broadcaster_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * When sending a multi-part payment, this secret is used to identify a payment across HTLCs. - * Because it is generated by the recipient and included in the invoice, it also provides - * proof to the recipient that the payment was sent by someone with the generated invoice. + * The value to be sent to the counterparty */ -void FinalOnionHopData_set_payment_secret(struct LDKFinalOnionHopData *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES uint64_t CommitmentTransaction_to_countersignatory_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * The intended total amount that this payment is for. - * - * Message serialization may panic if this value is more than 21 million Bitcoin. + * The feerate paid per 1000-weight-unit in this commitment transaction. */ -uint64_t FinalOnionHopData_get_total_msat(const struct LDKFinalOnionHopData *NONNULL_PTR this_ptr); +MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * The intended total amount that this payment is for. + * Trust our pre-built transaction and derived transaction creation public keys. * - * Message serialization may panic if this value is more than 21 million Bitcoin. + * Applies a wrapper which allows access to these fields. + * + * This should only be used if you fully trust the builder of this object. It should not + * be used by an external signer - instead use the verify function. */ -void FinalOnionHopData_set_total_msat(struct LDKFinalOnionHopData *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Constructs a new FinalOnionHopData given each field + * Verify our pre-built transaction and derived transaction creation public keys. + * + * Applies a wrapper which allows access to these fields. + * + * An external validating signer must call this method before signing + * or using the built transaction. */ -MUST_USE_RES struct LDKFinalOnionHopData FinalOnionHopData_new(struct LDKThirtyTwoBytes payment_secret_arg, uint64_t total_msat_arg); +MUST_USE_RES struct LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg, const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); /** - * Creates a copy of the FinalOnionHopData + * Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKFinalOnionHopData FinalOnionHopData_clone(const struct LDKFinalOnionHopData *NONNULL_PTR orig); +void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_obj); /** - * Checks if two FinalOnionHopDatas contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The transaction ID of the built Bitcoin transaction */ -bool FinalOnionHopData_eq(const struct LDKFinalOnionHopData *NONNULL_PTR a, const struct LDKFinalOnionHopData *NONNULL_PTR b); +MUST_USE_RES struct LDKThirtyTwoBytes TrustedCommitmentTransaction_txid(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * Frees any resources used by the OnionPacket, if is_owned is set and inner is non-NULL. + * The pre-built Bitcoin commitment transaction */ -void OnionPacket_free(struct LDKOnionPacket this_obj); +MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_built_transaction(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * BOLT 4 version number. + * The pre-calculated transaction creation public keys. */ -uint8_t OnionPacket_get_version(const struct LDKOnionPacket *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * BOLT 4 version number. + * Should anchors be used. */ -void OnionPacket_set_version(struct LDKOnionPacket *NONNULL_PTR this_ptr, uint8_t val); +MUST_USE_RES struct LDKChannelTypeFeatures TrustedCommitmentTransaction_channel_type_features(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * In order to ensure we always return an error on onion decode in compliance with [BOLT - * #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to - * deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral - * public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd - * like. + * Get a signature for each HTLC which was included in the commitment transaction (ie for + * which HTLCOutputInCommitment::transaction_output_index.is_some()). * - * Returns a copy of the field. + * The returned Vec has one entry for each HTLC, and in the same order. + * + * This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All. */ -struct LDKCResult_PublicKeySecp256k1ErrorZ OnionPacket_get_public_key(const struct LDKOnionPacket *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_CVec_ECDSASignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKEntropySource *NONNULL_PTR entropy_source); /** - * In order to ensure we always return an error on onion decode in compliance with [BOLT - * #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to - * deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral - * public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd - * like. + * Returns the index of the revokeable output, i.e. the `to_local` output sending funds to + * the broadcaster, in the built transaction, if any exists. + * + * There are two cases where this may return `None`: + * - The balance of the revokeable output is below the dust limit (only found on commitments + * early in the channel's lifetime, i.e. before the channel reserve is met). + * - This commitment was created before LDK 0.0.117. In this case, the + * commitment transaction previously didn't contain enough information to locate the + * revokeable output. */ -void OnionPacket_set_public_key(struct LDKOnionPacket *NONNULL_PTR this_ptr, struct LDKCResult_PublicKeySecp256k1ErrorZ val); +MUST_USE_RES struct LDKCOption_usizeZ TrustedCommitmentTransaction_revokeable_output_index(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * HMAC to verify the integrity of hop_data. + * Helper method to build an unsigned justice transaction spending the revokeable + * `to_local` output to a destination script. Fee estimation accounts for the expected + * revocation witness data that will be added when signed. + * + * This method will error if the given fee rate results in a fee greater than the value + * of the output being spent, or if there exists no revokeable `to_local` output on this + * commitment transaction. See [`Self::revokeable_output_index`] for more details. + * + * The built transaction will allow fee bumping with RBF, and this method takes + * `feerate_per_kw` as an input such that multiple copies of a justice transaction at different + * fee rates may be built. */ -const uint8_t (*OnionPacket_get_hmac(const struct LDKOnionPacket *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKCResult_TransactionNoneZ TrustedCommitmentTransaction_build_to_local_justice_tx(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, uint64_t feerate_per_kw, struct LDKCVec_u8Z destination_script); /** - * HMAC to verify the integrity of hop_data. + * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a + * shared secret first. This prevents on-chain observers from discovering how many commitment + * transactions occurred in a channel before it was closed. + * + * This function gets the shared secret from relevant channel public keys and can be used to + * \"decrypt\" the commitment transaction number given a commitment transaction on-chain. */ -void OnionPacket_set_hmac(struct LDKOnionPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); /** - * Creates a copy of the OnionPacket + * Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL. */ -struct LDKOnionPacket OnionPacket_clone(const struct LDKOnionPacket *NONNULL_PTR orig); +void ShutdownScript_free(struct LDKShutdownScript this_obj); /** - * Generates a non-cryptographic 64-bit hash of the OnionPacket. + * Creates a copy of the ShutdownScript */ -uint64_t OnionPacket_hash(const struct LDKOnionPacket *NONNULL_PTR o); +struct LDKShutdownScript ShutdownScript_clone(const struct LDKShutdownScript *NONNULL_PTR orig); /** - * Checks if two OnionPackets contain equal inner contents. + * Checks if two ShutdownScripts contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool OnionPacket_eq(const struct LDKOnionPacket *NONNULL_PTR a, const struct LDKOnionPacket *NONNULL_PTR b); +bool ShutdownScript_eq(const struct LDKShutdownScript *NONNULL_PTR a, const struct LDKShutdownScript *NONNULL_PTR b); /** - * Frees any resources used by the TrampolineOnionPacket, if is_owned is set and inner is non-NULL. + * Frees any resources used by the InvalidShutdownScript, if is_owned is set and inner is non-NULL. */ -void TrampolineOnionPacket_free(struct LDKTrampolineOnionPacket this_obj); +void InvalidShutdownScript_free(struct LDKInvalidShutdownScript this_obj); /** - * Bolt 04 version number + * The script that did not meet the requirements from [BOLT #2]. + * + * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md */ -uint8_t TrampolineOnionPacket_get_version(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z InvalidShutdownScript_get_script(const struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr); /** - * Bolt 04 version number + * The script that did not meet the requirements from [BOLT #2]. + * + * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md */ -void TrampolineOnionPacket_set_version(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, uint8_t val); +void InvalidShutdownScript_set_script(struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data + * Constructs a new InvalidShutdownScript given each field */ -struct LDKPublicKey TrampolineOnionPacket_get_public_key(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg); /** - * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data + * Creates a copy of the InvalidShutdownScript */ -void TrampolineOnionPacket_set_public_key(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig); /** - * Encrypted payload for the next hop - * - * Returns a copy of the field. + * Serialize the ShutdownScript object into a byte array which can be read by ShutdownScript_read */ -struct LDKCVec_u8Z TrampolineOnionPacket_get_hop_data(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_PTR obj); /** - * Encrypted payload for the next hop + * Read a ShutdownScript from a byte array, created by ShutdownScript_write */ -void TrampolineOnionPacket_set_hop_data(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKCResult_ShutdownScriptDecodeErrorZ ShutdownScript_read(struct LDKu8slice ser); /** - * HMAC to verify the integrity of hop_data + * Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. */ -const uint8_t (*TrampolineOnionPacket_get_hmac(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wpkh(const uint8_t (*pubkey_hash)[20]); /** - * HMAC to verify the integrity of hop_data + * Generates a P2WSH script pubkey from the given [`WScriptHash`]. */ -void TrampolineOnionPacket_set_hmac(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wsh(const uint8_t (*script_hash)[32]); /** - * Constructs a new TrampolineOnionPacket given each field + * Generates a witness script pubkey from the given segwit version and program. + * + * Note for version-zero witness scripts you must use [`ShutdownScript::new_p2wpkh`] or + * [`ShutdownScript::new_p2wsh`] instead. + * + * # Errors + * + * This function may return an error if `program` is invalid for the segwit `version`. */ -MUST_USE_RES struct LDKTrampolineOnionPacket TrampolineOnionPacket_new(uint8_t version_arg, struct LDKPublicKey public_key_arg, struct LDKCVec_u8Z hop_data_arg, struct LDKThirtyTwoBytes hmac_arg); +MUST_USE_RES struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ ShutdownScript_new_witness_program(struct LDKWitnessProgram witness_program); /** - * Creates a copy of the TrampolineOnionPacket + * Converts the shutdown script into the underlying [`ScriptBuf`]. */ -struct LDKTrampolineOnionPacket TrampolineOnionPacket_clone(const struct LDKTrampolineOnionPacket *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_u8Z ShutdownScript_into_inner(struct LDKShutdownScript this_arg); /** - * Generates a non-cryptographic 64-bit hash of the TrampolineOnionPacket. + * Returns the [`PublicKey`] used for a P2WPKH shutdown script if constructed directly from it. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t TrampolineOnionPacket_hash(const struct LDKTrampolineOnionPacket *NONNULL_PTR o); +MUST_USE_RES struct LDKPublicKey ShutdownScript_as_legacy_pubkey(const struct LDKShutdownScript *NONNULL_PTR this_arg); /** - * Checks if two TrampolineOnionPackets contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Returns whether the shutdown script is compatible with the features as defined by BOLT #2. + * + * Specifically, checks for compliance with feature `option_shutdown_anysegwit`. */ -bool TrampolineOnionPacket_eq(const struct LDKTrampolineOnionPacket *NONNULL_PTR a, const struct LDKTrampolineOnionPacket *NONNULL_PTR b); +MUST_USE_RES bool ShutdownScript_is_compatible(const struct LDKShutdownScript *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR features); /** - * Serialize the TrampolineOnionPacket object into a byte array which can be read by TrampolineOnionPacket_read + * Get the string representation of a ShutdownScript object */ -struct LDKCVec_u8Z TrampolineOnionPacket_write(const struct LDKTrampolineOnionPacket *NONNULL_PTR obj); +struct LDKStr ShutdownScript_to_str(const struct LDKShutdownScript *NONNULL_PTR o); /** - * Get the string representation of a DecodeError object + * Frees any resources used by the ChannelId, if is_owned is set and inner is non-NULL. */ -struct LDKStr DecodeError_to_str(const struct LDKDecodeError *NONNULL_PTR o); +void ChannelId_free(struct LDKChannelId this_obj); + +const uint8_t (*ChannelId_get_a(const struct LDKChannelId *NONNULL_PTR this_ptr))[32]; + +void ChannelId_set_a(struct LDKChannelId *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read + * Constructs a new ChannelId given each field */ -struct LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *NONNULL_PTR obj); +MUST_USE_RES struct LDKChannelId ChannelId_new(struct LDKThirtyTwoBytes a_arg); /** - * Read a AcceptChannel from a byte array, created by AcceptChannel_write + * Creates a copy of the ChannelId */ -struct LDKCResult_AcceptChannelDecodeErrorZ AcceptChannel_read(struct LDKu8slice ser); +struct LDKChannelId ChannelId_clone(const struct LDKChannelId *NONNULL_PTR orig); /** - * Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read + * Checks if two ChannelIds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCVec_u8Z AcceptChannelV2_write(const struct LDKAcceptChannelV2 *NONNULL_PTR obj); +bool ChannelId_eq(const struct LDKChannelId *NONNULL_PTR a, const struct LDKChannelId *NONNULL_PTR b); /** - * Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write + * Generates a non-cryptographic 64-bit hash of the ChannelId. */ -struct LDKCResult_AcceptChannelV2DecodeErrorZ AcceptChannelV2_read(struct LDKu8slice ser); +uint64_t ChannelId_hash(const struct LDKChannelId *NONNULL_PTR o); /** - * Serialize the Stfu object into a byte array which can be read by Stfu_read + * Create _v1_ channel ID based on a funding TX ID and output index */ -struct LDKCVec_u8Z Stfu_write(const struct LDKStfu *NONNULL_PTR obj); +MUST_USE_RES struct LDKChannelId ChannelId_v1_from_funding_txid(const uint8_t (*txid)[32], uint16_t output_index); /** - * Read a Stfu from a byte array, created by Stfu_write + * Create _v1_ channel ID from a funding tx outpoint */ -struct LDKCResult_StfuDecodeErrorZ Stfu_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKChannelId ChannelId_v1_from_funding_outpoint(struct LDKOutPoint outpoint); /** - * Serialize the SpliceInit object into a byte array which can be read by SpliceInit_read + * Create a _temporary_ channel ID randomly, based on an entropy source. */ -struct LDKCVec_u8Z SpliceInit_write(const struct LDKSpliceInit *NONNULL_PTR obj); +MUST_USE_RES struct LDKChannelId ChannelId_temporary_from_entropy_source(const struct LDKEntropySource *NONNULL_PTR entropy_source); /** - * Read a SpliceInit from a byte array, created by SpliceInit_write + * Generic constructor; create a new channel ID from the provided data. + * Use a more specific `*_from_*` constructor when possible. */ -struct LDKCResult_SpliceInitDecodeErrorZ SpliceInit_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKChannelId ChannelId_from_bytes(struct LDKThirtyTwoBytes data); /** - * Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read + * Create a channel ID consisting of all-zeros data (e.g. when uninitialized or a placeholder). */ -struct LDKCVec_u8Z SpliceAck_write(const struct LDKSpliceAck *NONNULL_PTR obj); +MUST_USE_RES struct LDKChannelId ChannelId_new_zero(void); /** - * Read a SpliceAck from a byte array, created by SpliceAck_write + * Check whether ID is consisting of all zeros (uninitialized) */ -struct LDKCResult_SpliceAckDecodeErrorZ SpliceAck_read(struct LDKu8slice ser); +MUST_USE_RES bool ChannelId_is_zero(const struct LDKChannelId *NONNULL_PTR this_arg); /** - * Serialize the SpliceLocked object into a byte array which can be read by SpliceLocked_read + * Create _v2_ channel ID by concatenating the holder revocation basepoint with the counterparty + * revocation basepoint and hashing the result. The basepoints will be concatenated in increasing + * sorted order. */ -struct LDKCVec_u8Z SpliceLocked_write(const struct LDKSpliceLocked *NONNULL_PTR obj); +MUST_USE_RES struct LDKChannelId ChannelId_v2_from_revocation_basepoints(const struct LDKRevocationBasepoint *NONNULL_PTR ours, const struct LDKRevocationBasepoint *NONNULL_PTR theirs); /** - * Read a SpliceLocked from a byte array, created by SpliceLocked_write + * Create temporary _v2_ channel ID by concatenating a zeroed out basepoint with the holder + * revocation basepoint and hashing the result. */ -struct LDKCResult_SpliceLockedDecodeErrorZ SpliceLocked_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKChannelId ChannelId_temporary_v2_from_revocation_basepoint(const struct LDKRevocationBasepoint *NONNULL_PTR our_revocation_basepoint); /** - * Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read + * Serialize the ChannelId object into a byte array which can be read by ChannelId_read */ -struct LDKCVec_u8Z TxAddInput_write(const struct LDKTxAddInput *NONNULL_PTR obj); +struct LDKCVec_u8Z ChannelId_write(const struct LDKChannelId *NONNULL_PTR obj); /** - * Read a TxAddInput from a byte array, created by TxAddInput_write + * Read a ChannelId from a byte array, created by ChannelId_write */ -struct LDKCResult_TxAddInputDecodeErrorZ TxAddInput_read(struct LDKu8slice ser); +struct LDKCResult_ChannelIdDecodeErrorZ ChannelId_read(struct LDKu8slice ser); /** - * Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read + * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" + * See [`PhantomKeysManager`] for more information on phantom node payments. + * + * `phantom_route_hints` parameter: + * * Contains channel info for all nodes participating in the phantom invoice + * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each + * participating node + * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is + * updated when a channel becomes disabled or closes + * * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice + * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared + * down + * + * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference + * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). + * If `None` is provided for `payment_hash`, then one will be created. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. + * + * `duration_since_epoch` is the current time since epoch in seconds. + * + * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to + * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3. + * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block + * confirmations during routing. + * + * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom + * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this + * requirement). + * + * [`PhantomKeysManager`]: crate::sign::PhantomKeysManager + * [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash + * [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels + * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA + * + *This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller. */ -struct LDKCVec_u8Z TxAddOutput_write(const struct LDKTxAddOutput *NONNULL_PTR obj); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); /** - * Read a TxAddOutput from a byte array, created by TxAddOutput_write + * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" + * See [`PhantomKeysManager`] for more information on phantom node payments. + * + * `phantom_route_hints` parameter: + * * Contains channel info for all nodes participating in the phantom invoice + * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each + * participating node + * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is + * updated when a channel becomes disabled or closes + * * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum + * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected + * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node + * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as + * desired, but note that some nodes will be trimmed if more than 3 nodes are provided. + * + * `description_hash` is a SHA-256 hash of the description text + * + * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference + * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). + * If `None` is provided for `payment_hash`, then one will be created. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. + * + * `duration_since_epoch` is the current time since epoch in seconds. + * + * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom + * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this + * requirement). + * + * [`PhantomKeysManager`]: crate::sign::PhantomKeysManager + * [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash + * [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels + * + *This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller. */ -struct LDKCResult_TxAddOutputDecodeErrorZ TxAddOutput_read(struct LDKu8slice ser); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ payment_hash, uint32_t invoice_expiry_delta_secs, struct LDKSha256 description_hash, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); /** - * Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read + * Utility to construct an invoice. Generally, unless you want to do something like a custom + * cltv_expiry, this is what you should be using to create an invoice. The reason being, this + * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user + * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify + * that the payment secret is valid when the invoice is paid. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. + * + * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to + * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. + * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block + * confirmations during routing. + * + * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA */ -struct LDKCVec_u8Z TxRemoveInput_write(const struct LDKTxRemoveInput *NONNULL_PTR obj); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * Read a TxRemoveInput from a byte array, created by TxRemoveInput_write + * Utility to construct an invoice. Generally, unless you want to do something like a custom + * cltv_expiry, this is what you should be using to create an invoice. The reason being, this + * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user + * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify + * that the payment secret is valid when the invoice is paid. + * Use this variant if you want to pass the `description_hash` to the invoice. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. + * + * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to + * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. + * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block + * confirmations during routing. + * + * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA */ -struct LDKCResult_TxRemoveInputDecodeErrorZ TxRemoveInput_read(struct LDKu8slice ser); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read + * See [`create_invoice_from_channelmanager`]. + * + * This version allows for providing custom [`PaymentHash`] and description hash for the invoice. + * + * This may be useful if you're building an on-chain swap or involving another protocol where + * the payment hash is also involved outside the scope of lightning and want to set the + * description hash. */ -struct LDKCVec_u8Z TxRemoveOutput_write(const struct LDKTxRemoveOutput *NONNULL_PTR obj); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_payment_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint32_t invoice_expiry_delta_secs, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write + * See [`create_invoice_from_channelmanager`]. + * + * This version allows for providing a custom [`PaymentHash`] for the invoice. + * This may be useful if you're building an on-chain swap or involving another protocol where + * the payment hash is also involved outside the scope of lightning. */ -struct LDKCResult_TxRemoveOutputDecodeErrorZ TxRemoveOutput_read(struct LDKu8slice ser); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_payment_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * Serialize the TxComplete object into a byte array which can be read by TxComplete_read + * Builds the necessary parameters to pay or pre-flight probe the given variable-amount + * (also known as 'zero-amount') [`Bolt11Invoice`] using + * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. + * + * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the + * same [`PaymentHash`] has never been paid before. + * + * Will always succeed unless the invoice has an amount specified, in which case + * [`payment_parameters_from_invoice`] should be used. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes */ -struct LDKCVec_u8Z TxComplete_write(const struct LDKTxComplete *NONNULL_PTR obj); +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_variable_amount_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice, uint64_t amount_msat); /** - * Read a TxComplete from a byte array, created by TxComplete_write + * Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using + * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. + * + * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the + * same [`PaymentHash`] has never been paid before. + * + * Will always succeed unless the invoice has no amount specified, in which case + * [`payment_parameters_from_variable_amount_invoice`] should be used. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes */ -struct LDKCResult_TxCompleteDecodeErrorZ TxComplete_read(struct LDKu8slice ser); +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice); /** - * Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read + * Frees any resources used by the Retry */ -struct LDKCVec_u8Z TxSignatures_write(const struct LDKTxSignatures *NONNULL_PTR obj); +void Retry_free(struct LDKRetry this_ptr); /** - * Read a TxSignatures from a byte array, created by TxSignatures_write + * Creates a copy of the Retry */ -struct LDKCResult_TxSignaturesDecodeErrorZ TxSignatures_read(struct LDKu8slice ser); +struct LDKRetry Retry_clone(const struct LDKRetry *NONNULL_PTR orig); /** - * Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read + * Utility method to constructs a new Attempts-variant Retry */ -struct LDKCVec_u8Z TxInitRbf_write(const struct LDKTxInitRbf *NONNULL_PTR obj); +struct LDKRetry Retry_attempts(uint32_t a); /** - * Read a TxInitRbf from a byte array, created by TxInitRbf_write + * Utility method to constructs a new Timeout-variant Retry */ -struct LDKCResult_TxInitRbfDecodeErrorZ TxInitRbf_read(struct LDKu8slice ser); +struct LDKRetry Retry_timeout(uint64_t a); /** - * Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read + * Checks if two Retrys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCVec_u8Z TxAckRbf_write(const struct LDKTxAckRbf *NONNULL_PTR obj); +bool Retry_eq(const struct LDKRetry *NONNULL_PTR a, const struct LDKRetry *NONNULL_PTR b); /** - * Read a TxAckRbf from a byte array, created by TxAckRbf_write + * Generates a non-cryptographic 64-bit hash of the Retry. */ -struct LDKCResult_TxAckRbfDecodeErrorZ TxAckRbf_read(struct LDKu8slice ser); +uint64_t Retry_hash(const struct LDKRetry *NONNULL_PTR o); /** - * Serialize the TxAbort object into a byte array which can be read by TxAbort_read + * Serialize the Retry object into a byte array which can be read by Retry_read */ -struct LDKCVec_u8Z TxAbort_write(const struct LDKTxAbort *NONNULL_PTR obj); +struct LDKCVec_u8Z Retry_write(const struct LDKRetry *NONNULL_PTR obj); /** - * Read a TxAbort from a byte array, created by TxAbort_write + * Read a Retry from a byte array, created by Retry_write */ -struct LDKCResult_TxAbortDecodeErrorZ TxAbort_read(struct LDKu8slice ser); +struct LDKCResult_RetryDecodeErrorZ Retry_read(struct LDKu8slice ser); /** - * Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read + * Creates a copy of the RetryableSendFailure */ -struct LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *NONNULL_PTR obj); +enum LDKRetryableSendFailure RetryableSendFailure_clone(const enum LDKRetryableSendFailure *NONNULL_PTR orig); /** - * Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write + * Utility method to constructs a new PaymentExpired-variant RetryableSendFailure */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ AnnouncementSignatures_read(struct LDKu8slice ser); +enum LDKRetryableSendFailure RetryableSendFailure_payment_expired(void); /** - * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read + * Utility method to constructs a new RouteNotFound-variant RetryableSendFailure */ -struct LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *NONNULL_PTR obj); +enum LDKRetryableSendFailure RetryableSendFailure_route_not_found(void); /** - * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write + * Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure */ -struct LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser); +enum LDKRetryableSendFailure RetryableSendFailure_duplicate_payment(void); /** - * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read + * Utility method to constructs a new OnionPacketSizeExceeded-variant RetryableSendFailure */ -struct LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *NONNULL_PTR obj); +enum LDKRetryableSendFailure RetryableSendFailure_onion_packet_size_exceeded(void); /** - * Read a ClosingSigned from a byte array, created by ClosingSigned_write + * Checks if two RetryableSendFailures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser); +bool RetryableSendFailure_eq(const enum LDKRetryableSendFailure *NONNULL_PTR a, const enum LDKRetryableSendFailure *NONNULL_PTR b); /** - * Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read + * Frees any resources used by the Bolt12PaymentError */ -struct LDKCVec_u8Z ClosingSignedFeeRange_write(const struct LDKClosingSignedFeeRange *NONNULL_PTR obj); +void Bolt12PaymentError_free(struct LDKBolt12PaymentError this_ptr); /** - * Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write + * Creates a copy of the Bolt12PaymentError */ -struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ ClosingSignedFeeRange_read(struct LDKu8slice ser); +struct LDKBolt12PaymentError Bolt12PaymentError_clone(const struct LDKBolt12PaymentError *NONNULL_PTR orig); /** - * Serialize the CommitmentSignedBatch object into a byte array which can be read by CommitmentSignedBatch_read + * Utility method to constructs a new UnexpectedInvoice-variant Bolt12PaymentError */ -struct LDKCVec_u8Z CommitmentSignedBatch_write(const struct LDKCommitmentSignedBatch *NONNULL_PTR obj); +struct LDKBolt12PaymentError Bolt12PaymentError_unexpected_invoice(void); /** - * Read a CommitmentSignedBatch from a byte array, created by CommitmentSignedBatch_write + * Utility method to constructs a new DuplicateInvoice-variant Bolt12PaymentError */ -struct LDKCResult_CommitmentSignedBatchDecodeErrorZ CommitmentSignedBatch_read(struct LDKu8slice ser); +struct LDKBolt12PaymentError Bolt12PaymentError_duplicate_invoice(void); /** - * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read + * Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12PaymentError */ -struct LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *NONNULL_PTR obj); +struct LDKBolt12PaymentError Bolt12PaymentError_unknown_required_features(void); /** - * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write + * Utility method to constructs a new SendingFailed-variant Bolt12PaymentError */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CommitmentSigned_read(struct LDKu8slice ser); +struct LDKBolt12PaymentError Bolt12PaymentError_sending_failed(enum LDKRetryableSendFailure a); /** - * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read + * Checks if two Bolt12PaymentErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *NONNULL_PTR obj); +bool Bolt12PaymentError_eq(const struct LDKBolt12PaymentError *NONNULL_PTR a, const struct LDKBolt12PaymentError *NONNULL_PTR b); /** - * Read a FundingCreated from a byte array, created by FundingCreated_write + * Frees any resources used by the ProbeSendFailure */ -struct LDKCResult_FundingCreatedDecodeErrorZ FundingCreated_read(struct LDKu8slice ser); +void ProbeSendFailure_free(struct LDKProbeSendFailure this_ptr); /** - * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read + * Creates a copy of the ProbeSendFailure */ -struct LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *NONNULL_PTR obj); +struct LDKProbeSendFailure ProbeSendFailure_clone(const struct LDKProbeSendFailure *NONNULL_PTR orig); /** - * Read a FundingSigned from a byte array, created by FundingSigned_write + * Utility method to constructs a new RouteNotFound-variant ProbeSendFailure */ -struct LDKCResult_FundingSignedDecodeErrorZ FundingSigned_read(struct LDKu8slice ser); +struct LDKProbeSendFailure ProbeSendFailure_route_not_found(void); /** - * Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read + * Utility method to constructs a new ParameterError-variant ProbeSendFailure */ -struct LDKCVec_u8Z ChannelReady_write(const struct LDKChannelReady *NONNULL_PTR obj); +struct LDKProbeSendFailure ProbeSendFailure_parameter_error(struct LDKAPIError a); /** - * Read a ChannelReady from a byte array, created by ChannelReady_write + * Utility method to constructs a new DuplicateProbe-variant ProbeSendFailure */ -struct LDKCResult_ChannelReadyDecodeErrorZ ChannelReady_read(struct LDKu8slice ser); +struct LDKProbeSendFailure ProbeSendFailure_duplicate_probe(void); /** - * Serialize the Init object into a byte array which can be read by Init_read + * Checks if two ProbeSendFailures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCVec_u8Z Init_write(const struct LDKInit *NONNULL_PTR obj); +bool ProbeSendFailure_eq(const struct LDKProbeSendFailure *NONNULL_PTR a, const struct LDKProbeSendFailure *NONNULL_PTR b); /** - * Read a Init from a byte array, created by Init_write + * Frees any resources used by the RecipientOnionFields, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser); +void RecipientOnionFields_free(struct LDKRecipientOnionFields this_obj); /** - * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read + * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat + * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to + * authenticate the sender to the recipient and prevent payment-probing (deanonymization) + * attacks. + * + * If you do not have one, the [`Route`] you pay over must not contain multiple paths as + * multi-path payments require a recipient-provided secret. + * + * Some implementations may reject spontaneous payments with payment secrets, so you may only + * want to provide a secret for a spontaneous payment if MPP is needed and you know your + * recipient will not reject it. */ -struct LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *NONNULL_PTR obj); +struct LDKCOption_ThirtyTwoBytesZ RecipientOnionFields_get_payment_secret(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); /** - * Read a OpenChannel from a byte array, created by OpenChannel_write + * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat + * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to + * authenticate the sender to the recipient and prevent payment-probing (deanonymization) + * attacks. + * + * If you do not have one, the [`Route`] you pay over must not contain multiple paths as + * multi-path payments require a recipient-provided secret. + * + * Some implementations may reject spontaneous payments with payment secrets, so you may only + * want to provide a secret for a spontaneous payment if MPP is needed and you know your + * recipient will not reject it. */ -struct LDKCResult_OpenChannelDecodeErrorZ OpenChannel_read(struct LDKu8slice ser); +void RecipientOnionFields_set_payment_secret(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); /** - * Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read + * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of + * arbitrary length. This gives recipients substantially more flexibility to receive + * additional data. + * + * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication + * scheme to authenticate received payments against expected payments and invoices, this field + * is not used in LDK for received payments, and can be used to store arbitrary data in + * invoices which will be received with the payment. + * + * Note that this field was added to the lightning specification more recently than + * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata + * may not be supported as universally. + * + * Returns a copy of the field. */ -struct LDKCVec_u8Z OpenChannelV2_write(const struct LDKOpenChannelV2 *NONNULL_PTR obj); +struct LDKCOption_CVec_u8ZZ RecipientOnionFields_get_payment_metadata(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); /** - * Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write + * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of + * arbitrary length. This gives recipients substantially more flexibility to receive + * additional data. + * + * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication + * scheme to authenticate received payments against expected payments and invoices, this field + * is not used in LDK for received payments, and can be used to store arbitrary data in + * invoices which will be received with the payment. + * + * Note that this field was added to the lightning specification more recently than + * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata + * may not be supported as universally. */ -struct LDKCResult_OpenChannelV2DecodeErrorZ OpenChannelV2_read(struct LDKu8slice ser); +void RecipientOnionFields_set_payment_metadata(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); /** - * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read + * Creates a copy of the RecipientOnionFields */ -struct LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *NONNULL_PTR obj); +struct LDKRecipientOnionFields RecipientOnionFields_clone(const struct LDKRecipientOnionFields *NONNULL_PTR orig); /** - * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write + * Checks if two RecipientOnionFieldss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCResult_RevokeAndACKDecodeErrorZ RevokeAndACK_read(struct LDKu8slice ser); +bool RecipientOnionFields_eq(const struct LDKRecipientOnionFields *NONNULL_PTR a, const struct LDKRecipientOnionFields *NONNULL_PTR b); /** - * Serialize the Shutdown object into a byte array which can be read by Shutdown_read + * Serialize the RecipientOnionFields object into a byte array which can be read by RecipientOnionFields_read */ -struct LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *NONNULL_PTR obj); +struct LDKCVec_u8Z RecipientOnionFields_write(const struct LDKRecipientOnionFields *NONNULL_PTR obj); /** - * Read a Shutdown from a byte array, created by Shutdown_write + * Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write */ -struct LDKCResult_ShutdownDecodeErrorZ Shutdown_read(struct LDKu8slice ser); +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ RecipientOnionFields_read(struct LDKu8slice ser); /** - * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read + * Creates a [`RecipientOnionFields`] from only a [`PaymentSecret`]. This is the most common + * set of onion fields for today's BOLT11 invoices - most nodes require a [`PaymentSecret`] + * but do not require or provide any further data. */ -struct LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *NONNULL_PTR obj); +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_secret_only(struct LDKThirtyTwoBytes payment_secret); /** - * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write + * Creates a new [`RecipientOnionFields`] with no fields. This generally does not create + * payable HTLCs except for single-path spontaneous payments, i.e. this should generally + * only be used for calls to [`ChannelManager::send_spontaneous_payment`]. If you are sending + * a spontaneous MPP this will not work as all MPP require payment secrets; you may + * instead want to use [`RecipientOnionFields::secret_only`]. + * + * [`ChannelManager::send_spontaneous_payment`]: super::channelmanager::ChannelManager::send_spontaneous_payment + * [`RecipientOnionFields::secret_only`]: RecipientOnionFields::secret_only */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ UpdateFailHTLC_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_spontaneous_empty(void); /** - * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read + * Creates a new [`RecipientOnionFields`] from an existing one, adding custom TLVs. Each + * TLV is provided as a `(u64, Vec)` for the type number and serialized value + * respectively. TLV type numbers must be unique and within the range + * reserved for custom types, i.e. >= 2^16, otherwise this method will return `Err(())`. + * + * This method will also error for types in the experimental range which have been + * standardized within the protocol, which only includes 5482373484 (keysend) for now. + * + * See [`Self::custom_tlvs`] for more info. */ -struct LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_RecipientOnionFieldsNoneZ RecipientOnionFields_with_custom_tlvs(struct LDKRecipientOnionFields this_arg, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs); /** - * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write + * Gets the custom TLVs that will be sent or have been received. + * + * Custom TLVs allow sending extra application-specific data with a payment. They provide + * additional flexibility on top of payment metadata, as while other implementations may + * require `payment_metadata` to reflect metadata provided in an invoice, custom TLVs + * do not have this restriction. + * + * Note that if this field is non-empty, it will contain strictly increasing TLVs, each + * represented by a `(u64, Vec)` for its type number and serialized value respectively. + * This is validated when setting this field using [`Self::with_custom_tlvs`]. */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ UpdateFailMalformedHTLC_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCVec_C2Tuple_u64CVec_u8ZZZ RecipientOnionFields_custom_tlvs(const struct LDKRecipientOnionFields *NONNULL_PTR this_arg); /** - * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read + * Calls the free function if one is set */ -struct LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *NONNULL_PTR obj); +void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); /** - * Read a UpdateFee from a byte array, created by UpdateFee_write + * Creates a copy of a Type */ -struct LDKCResult_UpdateFeeDecodeErrorZ UpdateFee_read(struct LDKu8slice ser); +struct LDKType Type_clone(const struct LDKType *NONNULL_PTR orig); /** - * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read + * Calls the free function if one is set */ -struct LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *NONNULL_PTR obj); +void Type_free(struct LDKType this_ptr); /** - * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write + * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ UpdateFulfillHTLC_read(struct LDKu8slice ser); +struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); /** - * Serialize the OnionPacket object into a byte array which can be read by OnionPacket_read + * Read a InitFeatures from a byte array, created by InitFeatures_write */ -struct LDKCVec_u8Z OnionPacket_write(const struct LDKOnionPacket *NONNULL_PTR obj); +struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); /** - * Read a OnionPacket from a byte array, created by OnionPacket_write + * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read */ -struct LDKCResult_OnionPacketDecodeErrorZ OnionPacket_read(struct LDKu8slice ser); +struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); /** - * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read + * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write */ -struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PTR obj); +struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); /** - * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write + * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); +struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); /** - * Read a OnionMessage from a byte array, created by OnionMessage_write + * Read a NodeFeatures from a byte array, created by NodeFeatures_write */ -struct LDKCResult_OnionMessageDecodeErrorZ OnionMessage_read(struct LDKu8slice ser); +struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); /** - * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read + * Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read */ -struct LDKCVec_u8Z OnionMessage_write(const struct LDKOnionMessage *NONNULL_PTR obj); +struct LDKCVec_u8Z Bolt11InvoiceFeatures_write(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR obj); /** - * Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read + * Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write */ -struct LDKCVec_u8Z FinalOnionHopData_write(const struct LDKFinalOnionHopData *NONNULL_PTR obj); +struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ Bolt11InvoiceFeatures_read(struct LDKu8slice ser); /** - * Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write + * Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read */ -struct LDKCResult_FinalOnionHopDataDecodeErrorZ FinalOnionHopData_read(struct LDKu8slice ser); +struct LDKCVec_u8Z Bolt12InvoiceFeatures_write(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR obj); /** - * Serialize the Ping object into a byte array which can be read by Ping_read + * Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write */ -struct LDKCVec_u8Z Ping_write(const struct LDKPing *NONNULL_PTR obj); +struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ Bolt12InvoiceFeatures_read(struct LDKu8slice ser); /** - * Read a Ping from a byte array, created by Ping_write + * Serialize the BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read */ -struct LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser); +struct LDKCVec_u8Z BlindedHopFeatures_write(const struct LDKBlindedHopFeatures *NONNULL_PTR obj); /** - * Serialize the Pong object into a byte array which can be read by Pong_read + * Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write */ -struct LDKCVec_u8Z Pong_write(const struct LDKPong *NONNULL_PTR obj); +struct LDKCResult_BlindedHopFeaturesDecodeErrorZ BlindedHopFeatures_read(struct LDKu8slice ser); /** - * Read a Pong from a byte array, created by Pong_write + * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read */ -struct LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser); +struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj); /** - * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read + * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write */ -struct LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR obj); +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser); /** - * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write + * Frees any resources used by the OfferId, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser); +void OfferId_free(struct LDKOfferId this_obj); + +const uint8_t (*OfferId_get_a(const struct LDKOfferId *NONNULL_PTR this_ptr))[32]; + +void OfferId_set_a(struct LDKOfferId *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read + * Constructs a new OfferId given each field */ -struct LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *NONNULL_PTR obj); +MUST_USE_RES struct LDKOfferId OfferId_new(struct LDKThirtyTwoBytes a_arg); /** - * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write + * Creates a copy of the OfferId */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ ChannelAnnouncement_read(struct LDKu8slice ser); +struct LDKOfferId OfferId_clone(const struct LDKOfferId *NONNULL_PTR orig); /** - * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read + * Checks if two OfferIds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *NONNULL_PTR obj); +bool OfferId_eq(const struct LDKOfferId *NONNULL_PTR a, const struct LDKOfferId *NONNULL_PTR b); /** - * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write + * Serialize the OfferId object into a byte array which can be read by OfferId_read */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser); +struct LDKCVec_u8Z OfferId_write(const struct LDKOfferId *NONNULL_PTR obj); /** - * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read + * Read a OfferId from a byte array, created by OfferId_write */ -struct LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *NONNULL_PTR obj); +struct LDKCResult_OfferIdDecodeErrorZ OfferId_read(struct LDKu8slice ser); /** - * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write + * Frees any resources used by the OfferWithExplicitMetadataBuilder, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ChannelUpdateDecodeErrorZ ChannelUpdate_read(struct LDKu8slice ser); +void OfferWithExplicitMetadataBuilder_free(struct LDKOfferWithExplicitMetadataBuilder this_obj); /** - * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read + * Creates a copy of the OfferWithExplicitMetadataBuilder */ -struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR obj); +struct LDKOfferWithExplicitMetadataBuilder OfferWithExplicitMetadataBuilder_clone(const struct LDKOfferWithExplicitMetadataBuilder *NONNULL_PTR orig); /** - * Read a ErrorMessage from a byte array, created by ErrorMessage_write + * Frees any resources used by the OfferWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); +void OfferWithDerivedMetadataBuilder_free(struct LDKOfferWithDerivedMetadataBuilder this_obj); /** - * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read + * Creates a copy of the OfferWithDerivedMetadataBuilder */ -struct LDKCVec_u8Z WarningMessage_write(const struct LDKWarningMessage *NONNULL_PTR obj); +struct LDKOfferWithDerivedMetadataBuilder OfferWithDerivedMetadataBuilder_clone(const struct LDKOfferWithDerivedMetadataBuilder *NONNULL_PTR orig); /** - * Read a WarningMessage from a byte array, created by WarningMessage_write + * Creates a new builder for an offer using the `signing_pubkey` for signing invoices. The + * associated secret key must be remembered while the offer is valid. + * + * Use a different pubkey per offer to avoid correlating offers. + * + * # Note + * + * If constructing an [`Offer`] for use with a [`ChannelManager`], use + * [`ChannelManager::create_offer_builder`] instead of [`OfferBuilder::new`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder */ -struct LDKCResult_WarningMessageDecodeErrorZ WarningMessage_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKOfferWithExplicitMetadataBuilder OfferWithExplicitMetadataBuilder_new(struct LDKPublicKey signing_pubkey); /** - * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read + * Sets the [`Offer::metadata`] to the given bytes. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ OfferWithExplicitMetadataBuilder_metadata(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKCVec_u8Z metadata); /** - * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write + * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, + * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. + * + * See [`Offer::chains`] on how this relates to the payment currency. + * + * Successive calls to this method will add another chain hash. */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_chain(struct LDKOfferWithExplicitMetadataBuilder this_arg, enum LDKNetwork network); /** - * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read + * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *NONNULL_PTR obj); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_amount_msats(struct LDKOfferWithExplicitMetadataBuilder this_arg, uint64_t amount_msats); /** - * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write + * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. + *Any expiry that has already passed is valid and can be checked for using [`Offer::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ NodeAnnouncement_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_absolute_expiry(struct LDKOfferWithExplicitMetadataBuilder this_arg, uint64_t absolute_expiry); /** - * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write + * Sets the [`Offer::description`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_description(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKStr description); /** - * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read + * Sets the [`Offer::issuer`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_issuer(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKStr issuer); /** - * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read + * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by + * private channels or if [`Offer::issuer_signing_pubkey`] is not a public node id. + * + * Successive calls to this method will add another blinded path. Caller is responsible for not + * adding duplicate paths. */ -struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_path(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKBlindedMessagePath path); /** - * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write + * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to + * [`Quantity::One`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_supported_quantity(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKQuantity quantity); /** - * Calculates the overflow safe ending block height for the query. - * - * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`. + * Builds an [`Offer`] from the builder's settings. */ -MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_OfferBolt12SemanticErrorZ OfferWithExplicitMetadataBuilder_build(struct LDKOfferWithExplicitMetadataBuilder this_arg); /** - * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read + * Similar to [`OfferBuilder::new`] except, if [`OfferBuilder::path`] is called, the signing + * pubkey is derived from the given [`ExpandedKey`] and [`Nonce`]. This provides recipient + * privacy by using a different signing pubkey for each offer. Otherwise, the provided + * `node_id` is used for [`Offer::issuer_signing_pubkey`]. + * + * Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by + * [`InvoiceRequest::verify_using_metadata`] to determine if the request was produced for the + * offer given an [`ExpandedKey`]. However, if [`OfferBuilder::path`] is called, then the + * metadata will not be set and must be included in each [`BlindedMessagePath`] instead. In this case, + * use [`InvoiceRequest::verify_using_recipient_data`]. + * + * [`InvoiceRequest::verify_using_metadata`]: crate::offers::invoice_request::InvoiceRequest::verify_using_metadata + * [`InvoiceRequest::verify_using_recipient_data`]: crate::offers::invoice_request::InvoiceRequest::verify_using_recipient_data + * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey */ -struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); +MUST_USE_RES struct LDKOfferWithDerivedMetadataBuilder OfferWithDerivedMetadataBuilder_deriving_signing_pubkey(struct LDKPublicKey node_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce); /** - * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write + * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, + * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. + * + * See [`Offer::chains`] on how this relates to the payment currency. + * + * Successive calls to this method will add another chain hash. */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_chain(struct LDKOfferWithDerivedMetadataBuilder this_arg, enum LDKNetwork network); /** - * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write + * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_amount_msats(struct LDKOfferWithDerivedMetadataBuilder this_arg, uint64_t amount_msats); /** - * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read + * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. + *Any expiry that has already passed is valid and can be checked for using [`Offer::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_absolute_expiry(struct LDKOfferWithDerivedMetadataBuilder this_arg, uint64_t absolute_expiry); /** - * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read + * Sets the [`Offer::description`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_description(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKStr description); /** - * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write + * Sets the [`Offer::issuer`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_issuer(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKStr issuer); /** - * Calls the free function if one is set + * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by + * private channels or if [`Offer::issuer_signing_pubkey`] is not a public node id. + * + * Successive calls to this method will add another blinded path. Caller is responsible for not + * adding duplicate paths. */ -void CustomMessageHandler_free(struct LDKCustomMessageHandler this_ptr); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_path(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKBlindedMessagePath path); /** - * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. + * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to + * [`Quantity::One`]. + * + * Successive calls to this method will override the previous setting. */ -void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_supported_quantity(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKQuantity quantity); /** - * Constructs a new IgnoringMessageHandler given each field + * Builds an [`Offer`] from the builder's settings. */ -MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); +MUST_USE_RES struct LDKCResult_OfferBolt12SemanticErrorZ OfferWithDerivedMetadataBuilder_build(struct LDKOfferWithDerivedMetadataBuilder this_arg); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Frees any resources used by the Offer, if is_owned is set and inner is non-NULL. */ -struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +void Offer_free(struct LDKOffer this_obj); /** - * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is + * Creates a copy of the Offer */ -struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +struct LDKOffer Offer_clone(const struct LDKOffer *NONNULL_PTR orig); /** - * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is + * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). + * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) + * for the selected chain. */ -struct LDKOnionMessageHandler IgnoringMessageHandler_as_OnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ Offer_chains(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is + * Opaque bytes set by the originator. Useful for authentication and validating fields since it + * is reflected in `invoice_request` messages along with all the other fields from the `offer`. */ -struct LDKOffersMessageHandler IgnoringMessageHandler_as_OffersMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ Offer_metadata(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is + * The minimum amount required for a successful payment of a single item. */ -struct LDKAsyncPaymentsMessageHandler IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_AmountZ Offer_amount(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Constructs a new DNSResolverMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned DNSResolverMessageHandler must be freed before this_arg is + * A complete description of the purpose of the payment. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKDNSResolverMessageHandler IgnoringMessageHandler_as_DNSResolverMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Offer_description(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Constructs a new CustomOnionMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CustomOnionMessageHandler must be freed before this_arg is + * Features pertaining to the offer. */ -struct LDKCustomOnionMessageHandler IgnoringMessageHandler_as_CustomOnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOfferFeatures Offer_offer_features(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Constructs a new CustomMessageReader which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CustomMessageReader must be freed before this_arg is + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * If `None`, the offer does not expire. */ -struct LDKCustomMessageReader IgnoringMessageHandler_as_CustomMessageReader(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z Offer_absolute_expiry(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Constructs a new CustomMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CustomMessageHandler must be freed before this_arg is + * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCustomMessageHandler IgnoringMessageHandler_as_CustomMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Offer_issuer(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Offer_paths(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Constructs a new ErroringMessageHandler + * The quantity of items supported. */ -MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); +MUST_USE_RES struct LDKQuantity Offer_supported_quantity(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * The public key corresponding to the key used by the recipient to sign invoices. + * - If [`Offer::paths`] is empty, MUST be `Some` and contain the recipient's node id for + * sending an [`InvoiceRequest`]. + * - If [`Offer::paths`] is not empty, MAY be `Some` and contain a transient id. + * - If `None`, the signing pubkey will be the final blinded node id from the + * [`BlindedMessagePath`] in [`Offer::paths`] used to send the [`InvoiceRequest`]. + * + * See also [`Bolt12Invoice::signing_pubkey`]. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice::signing_pubkey`]: crate::offers::invoice::Bolt12Invoice::signing_pubkey + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKMessageSendEventsProvider ErroringMessageHandler_as_MessageSendEventsProvider(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Offer_issuer_signing_pubkey(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is + * Returns the id of the offer. */ -struct LDKChannelMessageHandler ErroringMessageHandler_as_ChannelMessageHandler(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOfferId Offer_id(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. + * Returns whether the given chain is supported by the offer. */ -void MessageHandler_free(struct LDKMessageHandler this_obj); +MUST_USE_RES bool Offer_supports_chain(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes chain); /** - * A message handler which handles messages specific to channels. Usually this is just a - * [`ChannelManager`] object or an [`ErroringMessageHandler`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * Whether the offer has expired. */ -const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +MUST_USE_RES bool Offer_is_expired(const struct LDKOffer *NONNULL_PTR this_arg); /** - * A message handler which handles messages specific to channels. Usually this is just a - * [`ChannelManager`] object or an [`ErroringMessageHandler`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * Whether the offer has expired given the duration since the Unix epoch. */ -void MessageHandler_set_chan_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKChannelMessageHandler val); +MUST_USE_RES bool Offer_is_expired_no_std(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t duration_since_epoch); /** - * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. - * - * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync + * Returns whether the given quantity is valid for the offer. */ -const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +MUST_USE_RES bool Offer_is_valid_quantity(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t quantity); /** - * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. + * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer. * - * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest */ -void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); +MUST_USE_RES bool Offer_expects_quantity(const struct LDKOffer *NONNULL_PTR this_arg); /** - * A message handler which handles onion messages. This should generally be an - * [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. + * Creates an [`InvoiceRequestBuilder`] for the offer, which + * - derives the [`InvoiceRequest::payer_signing_pubkey`] such that a different key can be used + * for each request in order to protect the sender's privacy, + * - sets [`InvoiceRequest::payer_metadata`] when [`InvoiceRequestBuilder::build_and_sign`] is + * called such that it can be used by [`Bolt12Invoice::verify_using_metadata`] to determine + * if the invoice was requested using a base [`ExpandedKey`] from which the payer id was + * derived, and + * - includes the [`PaymentId`] encrypted in [`InvoiceRequest::payer_metadata`] so that it can + * be used when sending the payment for the requested invoice. * - * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + * Errors if the offer contains unknown required features. + * + * [`InvoiceRequest::payer_signing_pubkey`]: crate::offers::invoice_request::InvoiceRequest::payer_signing_pubkey + * [`InvoiceRequest::payer_metadata`]: crate::offers::invoice_request::InvoiceRequest::payer_metadata + * [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata + * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey */ -const struct LDKOnionMessageHandler *MessageHandler_get_onion_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_InvoiceRequestWithDerivedPayerSigningPubkeyBuilderBolt12SemanticErrorZ Offer_request_invoice(const struct LDKOffer *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce, struct LDKThirtyTwoBytes payment_id); /** - * A message handler which handles onion messages. This should generally be an - * [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. - * - * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + * Generates a non-cryptographic 64-bit hash of the Offer. */ -void MessageHandler_set_onion_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKOnionMessageHandler val); +uint64_t Offer_hash(const struct LDKOffer *NONNULL_PTR o); /** - * A message handler which handles custom messages. The only LDK-provided implementation is - * [`IgnoringMessageHandler`]. + * Read a Offer from a byte array, created by Offer_write */ -const struct LDKCustomMessageHandler *MessageHandler_get_custom_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +struct LDKCResult_OfferDecodeErrorZ Offer_read(struct LDKu8slice ser); /** - * A message handler which handles custom messages. The only LDK-provided implementation is - * [`IgnoringMessageHandler`]. + * Serialize the Offer object into a byte array which can be read by Offer_read */ -void MessageHandler_set_custom_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKCustomMessageHandler val); +struct LDKCVec_u8Z Offer_write(const struct LDKOffer *NONNULL_PTR obj); /** - * Constructs a new MessageHandler given each field + * Frees any resources used by the Amount */ -MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg, struct LDKOnionMessageHandler onion_message_handler_arg, struct LDKCustomMessageHandler custom_message_handler_arg); +void Amount_free(struct LDKAmount this_ptr); /** - * Creates a copy of a SocketDescriptor + * Creates a copy of the Amount */ -struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *NONNULL_PTR orig); +struct LDKAmount Amount_clone(const struct LDKAmount *NONNULL_PTR orig); /** - * Calls the free function if one is set + * Utility method to constructs a new Bitcoin-variant Amount */ -void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); +struct LDKAmount Amount_bitcoin(uint64_t amount_msats); /** - * Frees any resources used by the PeerDetails, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Currency-variant Amount */ -void PeerDetails_free(struct LDKPeerDetails this_obj); +struct LDKAmount Amount_currency(struct LDKThreeBytes iso4217_code, uint64_t amount); /** - * The node id of the peer. - * - * For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter - * passed in to [`PeerManager::new_outbound_connection`]. + * Frees any resources used by the Quantity */ -struct LDKPublicKey PeerDetails_get_counterparty_node_id(const struct LDKPeerDetails *NONNULL_PTR this_ptr); +void Quantity_free(struct LDKQuantity this_ptr); /** - * The node id of the peer. - * - * For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter - * passed in to [`PeerManager::new_outbound_connection`]. + * Creates a copy of the Quantity */ -void PeerDetails_set_counterparty_node_id(struct LDKPeerDetails *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKQuantity Quantity_clone(const struct LDKQuantity *NONNULL_PTR orig); /** - * The socket address the peer provided in the initial handshake. - * - * Will only be `Some` if an address had been previously provided to - * [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`]. - * - * Returns a copy of the field. + * Utility method to constructs a new Bounded-variant Quantity */ -struct LDKCOption_SocketAddressZ PeerDetails_get_socket_address(const struct LDKPeerDetails *NONNULL_PTR this_ptr); +struct LDKQuantity Quantity_bounded(uint64_t a); /** - * The socket address the peer provided in the initial handshake. - * - * Will only be `Some` if an address had been previously provided to - * [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`]. + * Utility method to constructs a new Unbounded-variant Quantity */ -void PeerDetails_set_socket_address(struct LDKPeerDetails *NONNULL_PTR this_ptr, struct LDKCOption_SocketAddressZ val); +struct LDKQuantity Quantity_unbounded(void); /** - * The features the peer provided in the initial handshake. + * Utility method to constructs a new One-variant Quantity */ -struct LDKInitFeatures PeerDetails_get_init_features(const struct LDKPeerDetails *NONNULL_PTR this_ptr); +struct LDKQuantity Quantity_one(void); /** - * The features the peer provided in the initial handshake. + * Read a Offer object from a string */ -void PeerDetails_set_init_features(struct LDKPeerDetails *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +struct LDKCResult_OfferBolt12ParseErrorZ Offer_from_str(struct LDKStr s); /** - * Indicates the direction of the peer connection. - * - * Will be `true` for inbound connections, and `false` for outbound connections. + * Get the string representation of a Offer object */ -bool PeerDetails_get_is_inbound_connection(const struct LDKPeerDetails *NONNULL_PTR this_ptr); +struct LDKStr Offer_to_str(const struct LDKOffer *NONNULL_PTR o); /** - * Indicates the direction of the peer connection. - * - * Will be `true` for inbound connections, and `false` for outbound connections. + * Frees any resources used by the InvoiceWithExplicitSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. */ -void PeerDetails_set_is_inbound_connection(struct LDKPeerDetails *NONNULL_PTR this_ptr, bool val); +void InvoiceWithExplicitSigningPubkeyBuilder_free(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_obj); /** - * Constructs a new PeerDetails given each field + * Frees any resources used by the InvoiceWithDerivedSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPeerDetails PeerDetails_new(struct LDKPublicKey counterparty_node_id_arg, struct LDKCOption_SocketAddressZ socket_address_arg, struct LDKInitFeatures init_features_arg, bool is_inbound_connection_arg); +void InvoiceWithDerivedSigningPubkeyBuilder_free(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_obj); /** - * Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. + * Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. */ -void PeerHandleError_free(struct LDKPeerHandleError this_obj); +MUST_USE_RES struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ InvoiceWithExplicitSigningPubkeyBuilder_build(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg); /** - * Constructs a new PeerHandleError given each field + *Sets the [`Bolt12Invoice::relative_expiry`] + *as seconds since [`Bolt12Invoice::created_at`]. + *Any expiry that has already passed is valid and can be checked for using + *[`Bolt12Invoice::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(void); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, uint32_t relative_expiry_secs); /** - * Creates a copy of the PeerHandleError + *Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. */ -struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError *NONNULL_PTR orig); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, const uint8_t (*script_hash)[32]); /** - * Get the string representation of a PeerHandleError object + *Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. */ -struct LDKStr PeerHandleError_to_str(const struct LDKPeerHandleError *NONNULL_PTR o); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, const uint8_t (*pubkey_hash)[20]); /** - * Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. + *Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2TR addresses. */ -void PeerManager_free(struct LDKPeerManager this_obj); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, struct LDKTweakedPublicKey output_key); /** - * Constructs a new `PeerManager` with the given message handlers. - * - * `ephemeral_random_data` is used to derive per-connection ephemeral keys and must be - * cryptographically secure random bytes. - * - * `current_time` is used as an always-increasing counter that survives across restarts and is - * incremented irregularly internally. In general it is best to simply use the current UNIX - * timestamp, however if it is not available a persistent counter that increases once per - * minute should suffice. + *Sets [`Bolt12Invoice::invoice_features`] + *to indicate MPP may be used. Otherwise, MPP is disallowed. */ -MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, uint32_t current_time, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKNodeSigner node_signer); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg); /** - * Returns a list of [`PeerDetails`] for connected peers that have completed the initial - * handshake. + * Builds a signed [`Bolt12Invoice`] after checking for valid semantics. */ -MUST_USE_RES struct LDKCVec_PeerDetailsZ PeerManager_list_peers(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg); /** - * Returns the [`PeerDetails`] of a connected peer that has completed the initial handshake. - * - * Will return `None` if the peer is unknown or it hasn't completed the initial handshake. + *Sets the [`Bolt12Invoice::relative_expiry`] + *as seconds since [`Bolt12Invoice::created_at`]. + *Any expiry that has already passed is valid and can be checked for using + *[`Bolt12Invoice::is_expired`]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES struct LDKPeerDetails PeerManager_peer_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, uint32_t relative_expiry_secs); /** - * Indicates a new outbound connection has been established to a node with the given `node_id` - * and an optional remote network address. - * - * The remote network address adds the option to report a remote IP address back to a connecting - * peer using the init message. - * The user should pass the remote network address of the host they are connected to. - * - * If an `Err` is returned here you must disconnect the connection immediately. - * - * Returns a small number of bytes to send to the remote node (currently always 50). - * - * Panics if descriptor is duplicative with some other descriptor which has not yet been - * [`socket_disconnected`]. + *Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. * - * [`socket_disconnected`]: PeerManager::socket_disconnected + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. */ -MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor, struct LDKCOption_SocketAddressZ remote_network_address); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, const uint8_t (*script_hash)[32]); /** - * Indicates a new inbound connection has been established to a node with an optional remote - * network address. - * - * The remote network address adds the option to report a remote IP address back to a connecting - * peer using the init message. - * The user should pass the remote network address of the host they are connected to. - * - * May refuse the connection by returning an Err, but will never write bytes to the remote end - * (outbound connector always speaks first). If an `Err` is returned here you must disconnect - * the connection immediately. - * - * Panics if descriptor is duplicative with some other descriptor which has not yet been - * [`socket_disconnected`]. + *Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. * - * [`socket_disconnected`]: PeerManager::socket_disconnected + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. */ -MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor, struct LDKCOption_SocketAddressZ remote_network_address); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, const uint8_t (*pubkey_hash)[20]); /** - * Indicates that there is room to write data to the given socket descriptor. - * - * May return an Err to indicate that the connection should be closed. - * - * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before - * returning. Thus, be very careful with reentrancy issues! The invariants around calling - * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be - * ready to call [`write_buffer_space_avail`] again if a write call generated here isn't - * sufficient! + *Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. * - * [`send_data`]: SocketDescriptor::send_data - * [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2TR addresses. */ -MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR descriptor); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, struct LDKTweakedPublicKey output_key); /** - * Indicates that data was read from the given socket descriptor. - * - * May return an Err to indicate that the connection should be closed. - * - * Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity. - * Thus, however, you should call [`process_events`] after any `read_event` to generate - * [`send_data`] calls to handle responses. - * - * If `Ok(true)` is returned, further read_events should not be triggered until a - * [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the - * send buffer). - * - * In order to avoid processing too many messages at once per peer, `data` should be on the - * order of 4KiB. - * - * [`send_data`]: SocketDescriptor::send_data - * [`process_events`]: PeerManager::process_events + *Sets [`Bolt12Invoice::invoice_features`] + *to indicate MPP may be used. Otherwise, MPP is disallowed. */ -MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR peer_descriptor, struct LDKu8slice data); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg); /** - * Checks for any events generated by our handlers and processes them. Includes sending most - * response messages as well as messages generated by calls to handler functions directly (eg - * functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]). - * - * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy - * issues! - * - * This should be called any time we may have messages to send. It is automatically called by - * [`lightning-net-tokio`] after processing incoming messages, and by - * [`lightning-background-processor`] when channel state has changed. Therefore, If you are not - * using both [`lightning-net-tokio`] and [`lightning-background-processor`], you may need to call - * this function manually to prevent messages from being delayed. - * - * Note that if there are any other calls to this function waiting on lock(s) this may return - * without doing any work. All available events that need handling will be handled before the - * other calls return. - * - * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards - * [`send_data`]: SocketDescriptor::send_data + * Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL. */ -void PeerManager_process_events(const struct LDKPeerManager *NONNULL_PTR this_arg); +void UnsignedBolt12Invoice_free(struct LDKUnsignedBolt12Invoice this_obj); /** - * Indicates that the given socket descriptor's connection is now closed. + * Creates a copy of the UnsignedBolt12Invoice */ -void PeerManager_socket_disconnected(const struct LDKPeerManager *NONNULL_PTR this_arg, const struct LDKSocketDescriptor *NONNULL_PTR descriptor); +struct LDKUnsignedBolt12Invoice UnsignedBolt12Invoice_clone(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR orig); /** - * Disconnect a peer given its node id. - * - * If a peer is connected, this will call [`disconnect_socket`] on the descriptor for the - * peer. Thus, be very careful about reentrancy issues. - * - * [`disconnect_socket`]: SocketDescriptor::disconnect_socket + * Calls the free function if one is set */ -void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id); +void SignBolt12InvoiceFn_free(struct LDKSignBolt12InvoiceFn this_ptr); /** - * Disconnects all currently-connected peers. This is useful on platforms where there may be - * an indication that TCP sockets have stalled even if we weren't around to time them out - * using regular ping/pongs. + * Returns the [`TaggedHash`] of the invoice to sign. */ -void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKTaggedHash UnsignedBolt12Invoice_tagged_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Send pings to each peer and disconnect those which did not respond to the last round of - * pings. - * - * This may be called on any timescale you want, however, roughly once every ten seconds is - * preferred. The call rate determines both how often we send a ping to our peers and how much - * time they have to respond before we disconnect them. - * - * May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy - * issues! - * - * [`send_data`]: SocketDescriptor::send_data + * Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL. */ -void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); +void Bolt12Invoice_free(struct LDKBolt12Invoice this_obj); /** - * Generates a signed node_announcement from the given arguments, sending it to all connected - * peers. Note that peers will likely ignore this message unless we have at least one public - * channel which has at least six confirmations on-chain. - * - * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this - * node to humans. They carry no in-protocol meaning. - * - * `addresses` represent the set (possibly empty) of socket addresses on which this node - * accepts incoming connections. These will be included in the node_announcement, publicly - * tying these addresses together and to this node. If you wish to preserve user privacy, - * addresses should likely contain only Tor Onion addresses. - * - * Panics if `addresses` is absurdly large (more than 100). - * - * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events + * Creates a copy of the Bolt12Invoice */ -void PeerManager_broadcast_node_announcement(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_SocketAddressZ addresses); +struct LDKBolt12Invoice Bolt12Invoice_clone(const struct LDKBolt12Invoice *NONNULL_PTR orig); /** - * Gets the weight for an HTLC-Success transaction. + * Paths to the recipient originating from publicly reachable nodes, including information + * needed for routing payments across them. + * + * Blinded paths provide recipient privacy by obfuscating its node id. Note, however, that this + * privacy is lost if a public node id is used for + *[`UnsignedBolt12Invoice::signing_pubkey`]. */ -uint64_t htlc_success_tx_weight(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); +MUST_USE_RES struct LDKCVec_BlindedPaymentPathZ UnsignedBolt12Invoice_payment_paths(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Gets the weight for an HTLC-Timeout transaction. + * Duration since the Unix epoch when the invoice was created. */ -uint64_t htlc_timeout_tx_weight(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); +MUST_USE_RES uint64_t UnsignedBolt12Invoice_created_at(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Creates a copy of the HTLCClaim + * Duration since + *[`UnsignedBolt12Invoice::created_at`] + * when the invoice has expired and therefore should no longer be paid. */ -enum LDKHTLCClaim HTLCClaim_clone(const enum LDKHTLCClaim *NONNULL_PTR orig); +MUST_USE_RES uint64_t UnsignedBolt12Invoice_relative_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OfferedTimeout-variant HTLCClaim + * Whether the invoice has expired. */ -enum LDKHTLCClaim HTLCClaim_offered_timeout(void); +MUST_USE_RES bool UnsignedBolt12Invoice_is_expired(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OfferedPreimage-variant HTLCClaim + * Fallback addresses for paying the invoice on-chain, in order of most-preferred to + * least-preferred. */ -enum LDKHTLCClaim HTLCClaim_offered_preimage(void); +MUST_USE_RES struct LDKCVec_AddressZ UnsignedBolt12Invoice_fallbacks(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Utility method to constructs a new AcceptedTimeout-variant HTLCClaim + * Features pertaining to paying an invoice. */ -enum LDKHTLCClaim HTLCClaim_accepted_timeout(void); +MUST_USE_RES struct LDKBolt12InvoiceFeatures UnsignedBolt12Invoice_invoice_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Utility method to constructs a new AcceptedPreimage-variant HTLCClaim + * A typically transient public key corresponding to the key used to sign the invoice. + * + * If the invoices was created in response to an [`Offer`], then this will be: + * - [`Offer::issuer_signing_pubkey`] if it's `Some`, otherwise + * - the final blinded node id from a [`BlindedMessagePath`] in [`Offer::paths`] if `None`. + * + * If the invoice was created in response to a [`Refund`], then it is a valid pubkey chosen by + * the recipient. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::issuer_signing_pubkey`]: crate::offers::offer::Offer::issuer_signing_pubkey + * [`Offer::paths`]: crate::offers::offer::Offer::paths + * [`Refund`]: crate::offers::refund::Refund */ -enum LDKHTLCClaim HTLCClaim_accepted_preimage(void); +MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_signing_pubkey(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Revocation-variant HTLCClaim + * The chains that may be used when paying a requested invoice. + * + * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. + * + * [`Offer::chains`]: crate::offers::offer::Offer::chains */ -enum LDKHTLCClaim HTLCClaim_revocation(void); +MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ UnsignedBolt12Invoice_offer_chains(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if two HTLCClaims contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the + * invoice originated from an offer. + * + * From [`InvoiceRequest::chain`] or [`Refund::chain`]. + * + * [`offer_chains`]: Self::offer_chains + * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain */ -bool HTLCClaim_eq(const enum LDKHTLCClaim *NONNULL_PTR a, const enum LDKHTLCClaim *NONNULL_PTR b); +MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_chain(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Check if a given input witness attempts to claim a HTLC. + * Opaque bytes set by the originating [`Offer`]. + * + * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or + * if the [`Offer`] did not set it. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::metadata`]: crate::offers::offer::Offer::metadata */ -MUST_USE_RES struct LDKCOption_HTLCClaimZ HTLCClaim_from_witness(struct LDKWitness witness); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedBolt12Invoice_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Build the commitment secret from the seed and the commitment number + * The minimum amount required for a successful payment of a single item. + * + * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if + * the [`Offer`] did not set it. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::amount`]: crate::offers::offer::Offer::amount */ -struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); +MUST_USE_RES struct LDKCOption_AmountZ UnsignedBolt12Invoice_amount(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Build a closing transaction + * Features pertaining to the originating [`Offer`]. + * + * From [`Offer::offer_features`]; `None` if the invoice was created in response to a + * [`Refund`]. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKTransaction build_closing_transaction(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); +MUST_USE_RES struct LDKOfferFeatures UnsignedBolt12Invoice_offer_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Frees any resources used by the CounterpartyCommitmentSecrets, if is_owned is set and inner is non-NULL. + * A complete description of the purpose of the originating offer or refund. + * + * From [`Offer::description`] or [`Refund::description`]. + * + * [`Offer::description`]: crate::offers::offer::Offer::description + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void CounterpartyCommitmentSecrets_free(struct LDKCounterpartyCommitmentSecrets this_obj); +MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_description(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Creates a copy of the CounterpartyCommitmentSecrets + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. + * + * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry */ -struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_clone(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR orig); +MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_absolute_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Creates a new empty `CounterpartyCommitmentSecrets` structure. + * The issuer of the offer or refund. + * + * From [`Offer::issuer`] or [`Refund::issuer`]. + * + * [`Offer::issuer`]: crate::offers::offer::Offer::issuer + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_new(void); +MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_issuer(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Returns the minimum index of all stored secrets. Note that indexes start - * at 1 << 48 and get decremented by one for each new secret. + * Paths to the recipient originating from publicly reachable nodes. + * + * From [`Offer::paths`] or [`Refund::paths`]. + * + * [`Offer::paths`]: crate::offers::offer::Offer::paths */ -MUST_USE_RES uint64_t CounterpartyCommitmentSecrets_get_min_seen_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ UnsignedBolt12Invoice_message_paths(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Inserts the `secret` at `idx`. Returns `Ok(())` if the secret - * was generated in accordance with BOLT 3 and is consistent with previous secrets. + * The quantity of items supported. + * + * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a + * [`Refund`]. + * + * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity */ -MUST_USE_RES struct LDKCResult_NoneNoneZ CounterpartyCommitmentSecrets_provide_secret(struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx, struct LDKThirtyTwoBytes secret); +MUST_USE_RES struct LDKCOption_QuantityZ UnsignedBolt12Invoice_supported_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Returns the secret at `idx`. - * Returns `None` if `idx` is < [`CounterpartyCommitmentSecrets::get_min_seen_secret`]. + * The public key used by the recipient to sign invoices. + * + * From [`Offer::issuer_signing_pubkey`] and may be `None`; also `None` if the invoice was + * created in response to a [`Refund`]. + * + * [`Offer::issuer_signing_pubkey`]: crate::offers::offer::Offer::issuer_signing_pubkey * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKThirtyTwoBytes CounterpartyCommitmentSecrets_get_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx); +MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_issuer_signing_pubkey(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read + * An unpredictable series of bytes from the payer. + * + * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. */ -struct LDKCVec_u8Z CounterpartyCommitmentSecrets_write(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR obj); +MUST_USE_RES struct LDKu8slice UnsignedBolt12Invoice_payer_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write + * Features pertaining to requesting an invoice. + * + * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CounterpartyCommitmentSecrets_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedBolt12Invoice_invoice_request_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) - * from the base secret and the per_commitment_point. + * The quantity of items requested or refunded for. + * + * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. */ -struct LDKSecretKey derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); +MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Derives a per-commitment-transaction revocation key from its constituent parts. + * A possibly transient pubkey used to sign the invoice request or to send an invoice for a + * refund in case there are no [`message_paths`]. * - * Only the cheating participant owns a valid witness to propagate a revoked - * commitment transaction, thus per_commitment_secret always come from cheater - * and revocation_base_secret always come from punisher, which is the broadcaster - * of the transaction spending with this key knowledge. + * [`message_paths`]: Self::message_paths */ -struct LDKSecretKey derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]); +MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_payer_signing_pubkey(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. + * A payer-provided note reflected back in the invoice. + * + * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void TxCreationKeys_free(struct LDKTxCreationKeys this_obj); +MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_payer_note(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * The broadcaster's per-commitment public key which was used to derive the other keys. + * SHA256 hash of the payment preimage that will be given in return for paying the invoice. */ -struct LDKPublicKey TxCreationKeys_get_per_commitment_point(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_payment_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * The broadcaster's per-commitment public key which was used to derive the other keys. + * The minimum amount required for a successful payment of the invoice. */ -void TxCreationKeys_set_per_commitment_point(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES uint64_t UnsignedBolt12Invoice_amount_msats(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * The revocation key which is used to allow the broadcaster of the commitment - * transaction to provide their counterparty the ability to punish them if they broadcast - * an old state. + * Paths to the recipient originating from publicly reachable nodes, including information + * needed for routing payments across them. + * + * Blinded paths provide recipient privacy by obfuscating its node id. Note, however, that this + * privacy is lost if a public node id is used for + *[`Bolt12Invoice::signing_pubkey`]. */ -struct LDKRevocationKey TxCreationKeys_get_revocation_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_BlindedPaymentPathZ Bolt12Invoice_payment_paths(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * The revocation key which is used to allow the broadcaster of the commitment - * transaction to provide their counterparty the ability to punish them if they broadcast - * an old state. + * Duration since the Unix epoch when the invoice was created. */ -void TxCreationKeys_set_revocation_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKRevocationKey val); +MUST_USE_RES uint64_t Bolt12Invoice_created_at(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Broadcaster's HTLC Key + * Duration since + *[`Bolt12Invoice::created_at`] + * when the invoice has expired and therefore should no longer be paid. */ -struct LDKHtlcKey TxCreationKeys_get_broadcaster_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES uint64_t Bolt12Invoice_relative_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Broadcaster's HTLC Key + * Whether the invoice has expired. */ -void TxCreationKeys_set_broadcaster_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKHtlcKey val); +MUST_USE_RES bool Bolt12Invoice_is_expired(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Countersignatory's HTLC Key + * Fallback addresses for paying the invoice on-chain, in order of most-preferred to + * least-preferred. */ -struct LDKHtlcKey TxCreationKeys_get_countersignatory_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_AddressZ Bolt12Invoice_fallbacks(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Countersignatory's HTLC Key + * Features pertaining to paying an invoice. */ -void TxCreationKeys_set_countersignatory_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKHtlcKey val); +MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12Invoice_invoice_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) + * A typically transient public key corresponding to the key used to sign the invoice. + * + * If the invoices was created in response to an [`Offer`], then this will be: + * - [`Offer::issuer_signing_pubkey`] if it's `Some`, otherwise + * - the final blinded node id from a [`BlindedMessagePath`] in [`Offer::paths`] if `None`. + * + * If the invoice was created in response to a [`Refund`], then it is a valid pubkey chosen by + * the recipient. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::issuer_signing_pubkey`]: crate::offers::offer::Offer::issuer_signing_pubkey + * [`Offer::paths`]: crate::offers::offer::Offer::paths + * [`Refund`]: crate::offers::refund::Refund */ -struct LDKDelayedPaymentKey TxCreationKeys_get_broadcaster_delayed_payment_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPublicKey Bolt12Invoice_signing_pubkey(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) + * The chains that may be used when paying a requested invoice. + * + * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. + * + * [`Offer::chains`]: crate::offers::offer::Offer::chains */ -void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKDelayedPaymentKey val); +MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ Bolt12Invoice_offer_chains(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new TxCreationKeys given each field + * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the + * invoice originated from an offer. + * + * From [`InvoiceRequest::chain`] or [`Refund::chain`]. + * + * [`offer_chains`]: Self::offer_chains + * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain */ -MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKRevocationKey revocation_key_arg, struct LDKHtlcKey broadcaster_htlc_key_arg, struct LDKHtlcKey countersignatory_htlc_key_arg, struct LDKDelayedPaymentKey broadcaster_delayed_payment_key_arg); +MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_chain(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if two TxCreationKeyss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Opaque bytes set by the originating [`Offer`]. + * + * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or + * if the [`Offer`] did not set it. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::metadata`]: crate::offers::offer::Offer::metadata */ -bool TxCreationKeys_eq(const struct LDKTxCreationKeys *NONNULL_PTR a, const struct LDKTxCreationKeys *NONNULL_PTR b); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ Bolt12Invoice_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Creates a copy of the TxCreationKeys + * The minimum amount required for a successful payment of a single item. + * + * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if + * the [`Offer`] did not set it. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::amount`]: crate::offers::offer::Offer::amount */ -struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *NONNULL_PTR orig); +MUST_USE_RES struct LDKCOption_AmountZ Bolt12Invoice_amount(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read + * Features pertaining to the originating [`Offer`]. + * + * From [`Offer::offer_features`]; `None` if the invoice was created in response to a + * [`Refund`]. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *NONNULL_PTR obj); +MUST_USE_RES struct LDKOfferFeatures Bolt12Invoice_offer_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write + * A complete description of the purpose of the originating offer or refund. + * + * From [`Offer::description`] or [`Refund::description`]. + * + * [`Offer::description`]: crate::offers::offer::Offer::description + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_TxCreationKeysDecodeErrorZ TxCreationKeys_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKPrintableString Bolt12Invoice_description(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. + * + * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry */ -void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_obj); +MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_absolute_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * The public key which is used to sign all commitment transactions, as it appears in the - * on-chain channel lock-in 2-of-2 multisig output. + * The issuer of the offer or refund. + * + * From [`Offer::issuer`] or [`Refund::issuer`]. + * + * [`Offer::issuer`]: crate::offers::offer::Offer::issuer + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPrintableString Bolt12Invoice_issuer(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * The public key which is used to sign all commitment transactions, as it appears in the - * on-chain channel lock-in 2-of-2 multisig output. + * Paths to the recipient originating from publicly reachable nodes. + * + * From [`Offer::paths`] or [`Refund::paths`]. + * + * [`Offer::paths`]: crate::offers::offer::Offer::paths */ -void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Bolt12Invoice_message_paths(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * The base point which is used (with [`RevocationKey::from_basepoint`]) to derive per-commitment - * revocation keys. This is combined with the per-commitment-secret generated by the - * counterparty to create a secret which the counterparty can reveal to revoke previous - * states. + * The quantity of items supported. + * + * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a + * [`Refund`]. + * + * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity */ -struct LDKRevocationBasepoint ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_QuantityZ Bolt12Invoice_supported_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * The base point which is used (with [`RevocationKey::from_basepoint`]) to derive per-commitment - * revocation keys. This is combined with the per-commitment-secret generated by the - * counterparty to create a secret which the counterparty can reveal to revoke previous - * states. + * The public key used by the recipient to sign invoices. + * + * From [`Offer::issuer_signing_pubkey`] and may be `None`; also `None` if the invoice was + * created in response to a [`Refund`]. + * + * [`Offer::issuer_signing_pubkey`]: crate::offers::offer::Offer::issuer_signing_pubkey + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelPublicKeys_set_revocation_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKRevocationBasepoint val); +MUST_USE_RES struct LDKPublicKey Bolt12Invoice_issuer_signing_pubkey(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately - * spendable primary channel balance on the broadcaster's commitment transaction. This key is - * static across every commitment transaction. + * An unpredictable series of bytes from the payer. + * + * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. */ -struct LDKPublicKey ChannelPublicKeys_get_payment_point(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKu8slice Bolt12Invoice_payer_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately - * spendable primary channel balance on the broadcaster's commitment transaction. This key is - * static across every commitment transaction. + * Features pertaining to requesting an invoice. + * + * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. */ -void ChannelPublicKeys_set_payment_point(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKInvoiceRequestFeatures Bolt12Invoice_invoice_request_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment payment - * public key which receives non-HTLC-encumbered funds which are only available for spending - * after some delay (or can be claimed via the revocation path). + * The quantity of items requested or refunded for. + * + * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. */ -struct LDKDelayedPaymentBasepoint ChannelPublicKeys_get_delayed_payment_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment payment - * public key which receives non-HTLC-encumbered funds which are only available for spending - * after some delay (or can be claimed via the revocation path). + * A possibly transient pubkey used to sign the invoice request or to send an invoice for a + * refund in case there are no [`message_paths`]. + * + * [`message_paths`]: Self::message_paths */ -void ChannelPublicKeys_set_delayed_payment_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKDelayedPaymentBasepoint val); +MUST_USE_RES struct LDKPublicKey Bolt12Invoice_payer_signing_pubkey(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment public key - * which is used to encumber HTLC-in-flight outputs. + * A payer-provided note reflected back in the invoice. + * + * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKHtlcBasepoint ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPrintableString Bolt12Invoice_payer_note(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment public key - * which is used to encumber HTLC-in-flight outputs. + * SHA256 hash of the payment preimage that will be given in return for paying the invoice. */ -void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKHtlcBasepoint val); +MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_payment_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new ChannelPublicKeys given each field + * The minimum amount required for a successful payment of the invoice. */ -MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKRevocationBasepoint revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKDelayedPaymentBasepoint delayed_payment_basepoint_arg, struct LDKHtlcBasepoint htlc_basepoint_arg); +MUST_USE_RES uint64_t Bolt12Invoice_amount_msats(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelPublicKeys + * Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`]. */ -struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); +MUST_USE_RES struct LDKSchnorrSignature Bolt12Invoice_signature(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the ChannelPublicKeys. + * Hash that was used for signing the invoice. */ -uint64_t ChannelPublicKeys_hash(const struct LDKChannelPublicKeys *NONNULL_PTR o); +MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_signable_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if two ChannelPublicKeyss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Verifies that the invoice was for a request or refund created using the given key by + * checking the payer metadata from the invoice request. + * + * Returns the associated [`PaymentId`] to use when sending the payment. */ -bool ChannelPublicKeys_eq(const struct LDKChannelPublicKeys *NONNULL_PTR a, const struct LDKChannelPublicKeys *NONNULL_PTR b); +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ Bolt12Invoice_verify_using_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read + * Verifies that the invoice was for a request or refund created using the given key by + * checking a payment id and nonce included with the [`BlindedMessagePath`] for which the invoice was + * sent through. */ -struct LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ Bolt12Invoice_verify_using_payer_data(const struct LDKBolt12Invoice *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id, struct LDKNonce nonce, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write + * Generates a non-cryptographic 64-bit hash of the Bolt12Invoice. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ ChannelPublicKeys_read(struct LDKu8slice ser); +uint64_t Bolt12Invoice_hash(const struct LDKBolt12Invoice *NONNULL_PTR o); /** - * Create per-state keys from channel base points and the per-commitment point. - * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. + * Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read */ -MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_derive_new(struct LDKPublicKey per_commitment_point, const struct LDKDelayedPaymentBasepoint *NONNULL_PTR broadcaster_delayed_payment_base, const struct LDKHtlcBasepoint *NONNULL_PTR broadcaster_htlc_base, const struct LDKRevocationBasepoint *NONNULL_PTR countersignatory_revocation_base, const struct LDKHtlcBasepoint *NONNULL_PTR countersignatory_htlc_base); +struct LDKCVec_u8Z UnsignedBolt12Invoice_write(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR obj); /** - * Generate per-state keys from channel static keys. - * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. + * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read */ -MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_from_channel_static_keys(struct LDKPublicKey per_commitment_point, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); +struct LDKCVec_u8Z Bolt12Invoice_write(const struct LDKBolt12Invoice *NONNULL_PTR obj); /** - * A script either spendable by the revocation - * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. - * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. + * Read a Bolt12Invoice from a byte array, created by Bolt12Invoice_write */ -struct LDKCVec_u8Z get_revokeable_redeemscript(const struct LDKRevocationKey *NONNULL_PTR revocation_key, uint16_t contest_delay, const struct LDKDelayedPaymentKey *NONNULL_PTR broadcaster_delayed_payment_key); +struct LDKCResult_Bolt12InvoiceDecodeErrorZ Bolt12Invoice_read(struct LDKu8slice ser); /** - * Returns the script for the counterparty's output on a holder's commitment transaction based on - * the channel type. + * Frees any resources used by the InvoiceError, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z get_counterparty_payment_script(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, struct LDKPublicKey payment_key); +void InvoiceError_free(struct LDKInvoiceError this_obj); /** - * Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. + * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_obj); +struct LDKErroneousField InvoiceError_get_erroneous_field(const struct LDKInvoiceError *NONNULL_PTR this_ptr); /** - * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). - * Note that this is not the same as whether it is ountbound *from us*. To determine that you - * need to compare this value to whether the commitment transaction in question is that of - * the counterparty or our own. + * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -bool HTLCOutputInCommitment_get_offered(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +void InvoiceError_set_erroneous_field(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKErroneousField val); /** - * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). - * Note that this is not the same as whether it is ountbound *from us*. To determine that you - * need to compare this value to whether the commitment transaction in question is that of - * the counterparty or our own. + * An explanation of the error. */ -void HTLCOutputInCommitment_set_offered(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, bool val); +struct LDKUntrustedString InvoiceError_get_message(const struct LDKInvoiceError *NONNULL_PTR this_ptr); /** - * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is - * this divided by 1000. + * An explanation of the error. */ -uint64_t HTLCOutputInCommitment_get_amount_msat(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +void InvoiceError_set_message(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKUntrustedString val); /** - * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is - * this divided by 1000. + * Constructs a new InvoiceError given each field + * + * Note that erroneous_field_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void HTLCOutputInCommitment_set_amount_msat(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKInvoiceError InvoiceError_new(struct LDKErroneousField erroneous_field_arg, struct LDKUntrustedString message_arg); /** - * The CLTV lock-time at which this HTLC expires. + * Creates a copy of the InvoiceError */ -uint32_t HTLCOutputInCommitment_get_cltv_expiry(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +struct LDKInvoiceError InvoiceError_clone(const struct LDKInvoiceError *NONNULL_PTR orig); /** - * The CLTV lock-time at which this HTLC expires. + * Frees any resources used by the ErroneousField, if is_owned is set and inner is non-NULL. */ -void HTLCOutputInCommitment_set_cltv_expiry(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint32_t val); +void ErroneousField_free(struct LDKErroneousField this_obj); /** - * The hash of the preimage which unlocks this HTLC. + * The type number of the TLV field containing the error. */ -const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr))[32]; +uint64_t ErroneousField_get_tlv_fieldnum(const struct LDKErroneousField *NONNULL_PTR this_ptr); /** - * The hash of the preimage which unlocks this HTLC. + * The type number of the TLV field containing the error. */ -void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ErroneousField_set_tlv_fieldnum(struct LDKErroneousField *NONNULL_PTR this_ptr, uint64_t val); /** - * The position within the commitment transactions' outputs. This may be None if the value is - * below the dust limit (in which case no output appears in the commitment transaction and the - * value is spent to additional transaction fees). + * A value to use for the TLV field to avoid the error. + * + * Returns a copy of the field. */ -struct LDKCOption_u32Z HTLCOutputInCommitment_get_transaction_output_index(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +struct LDKCOption_CVec_u8ZZ ErroneousField_get_suggested_value(const struct LDKErroneousField *NONNULL_PTR this_ptr); /** - * The position within the commitment transactions' outputs. This may be None if the value is - * below the dust limit (in which case no output appears in the commitment transaction and the - * value is spent to additional transaction fees). + * A value to use for the TLV field to avoid the error. */ -void HTLCOutputInCommitment_set_transaction_output_index(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +void ErroneousField_set_suggested_value(struct LDKErroneousField *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); /** - * Constructs a new HTLCOutputInCommitment given each field + * Constructs a new ErroneousField given each field */ -MUST_USE_RES struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_new(bool offered_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_u32Z transaction_output_index_arg); +MUST_USE_RES struct LDKErroneousField ErroneousField_new(uint64_t tlv_fieldnum_arg, struct LDKCOption_CVec_u8ZZ suggested_value_arg); /** - * Creates a copy of the HTLCOutputInCommitment + * Creates a copy of the ErroneousField */ -struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); +struct LDKErroneousField ErroneousField_clone(const struct LDKErroneousField *NONNULL_PTR orig); /** - * Checks if two HTLCOutputInCommitments contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates an [`InvoiceError`] with the given message. */ -bool HTLCOutputInCommitment_eq(const struct LDKHTLCOutputInCommitment *NONNULL_PTR a, const struct LDKHTLCOutputInCommitment *NONNULL_PTR b); +MUST_USE_RES struct LDKInvoiceError InvoiceError_from_string(struct LDKStr s); /** - * Converts HTLC's value with millisatoshi precision into [bitcoin::Amount] with satoshi precision. - * Typically this conversion is needed when transitioning from LN into base-layer Bitcoin, - * e. g. in commitment transactions. + * Get the string representation of a InvoiceError object */ -MUST_USE_RES uint64_t HTLCOutputInCommitment_to_bitcoin_amount(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_arg); +struct LDKStr InvoiceError_to_str(const struct LDKInvoiceError *NONNULL_PTR o); /** - * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read + * Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read */ -struct LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *NONNULL_PTR obj); +struct LDKCVec_u8Z InvoiceError_write(const struct LDKInvoiceError *NONNULL_PTR obj); /** - * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write + * Read a InvoiceError from a byte array, created by InvoiceError_write */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read(struct LDKu8slice ser); +struct LDKCResult_InvoiceErrorDecodeErrorZ InvoiceError_read(struct LDKu8slice ser); /** - * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc - * does not need to have its previous_output_index filled. + * Frees any resources used by the InvoiceRequestWithDerivedPayerSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, const struct LDKTxCreationKeys *NONNULL_PTR keys); +void InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_free(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_obj); /** - * Gets the redeemscript for a funding output from the two funding public keys. - * Note that the order of funding public keys does not matter. + * Builds a signed [`InvoiceRequest`] after checking for valid semantics. */ -struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); +MUST_USE_RES struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_build_and_sign(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg); /** - * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC - * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the - * transaction which needs signing, and can be used to construct an HTLC transaction which is - * broadcastable given a counterparty HTLC signature. + * Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not + * called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported + * by the offer. * - * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the - * commitment transaction). + * Successive calls to this method will override the previous setting. */ -struct LDKTransaction build_htlc_transaction(const uint8_t (*commitment_txid)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, const struct LDKDelayedPaymentKey *NONNULL_PTR broadcaster_delayed_payment_key, const struct LDKRevocationKey *NONNULL_PTR revocation_key); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_chain(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg, enum LDKNetwork network); /** - * Returns the witness required to satisfy and spend a HTLC input. + * Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is + * not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]). + * + * Successive calls to this method will override the previous setting. + * + * [`quantity`]: Self::quantity */ -struct LDKWitness build_htlc_input_witness(struct LDKECDSASignature local_sig, struct LDKECDSASignature remote_sig, struct LDKCOption_ThirtyTwoBytesZ preimage, struct LDKu8slice redeem_script, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_amount_msats(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg, uint64_t amount_msats); /** - * Gets the witnessScript for the to_remote output when anchors are enabled. + * Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity` + * does not conform to [`Offer::is_valid_quantity`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z get_to_countersignatory_with_anchors_redeemscript(struct LDKPublicKey payment_point); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_quantity(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg, uint64_t quantity); /** - * Gets the witnessScript for an anchor output from the funding public key. - * The witness in the spending input must be: - * - * After 16 blocks of confirmation, an alternative satisfying witness could be: - * <> - * (empty vector required to satisfy compliance with MINIMALIF-standard rule) + * Sets the [`InvoiceRequest::payer_note`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z get_anchor_redeemscript(struct LDKPublicKey funding_pubkey); +MUST_USE_RES void InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_payer_note(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg, struct LDKStr payer_note); /** - * Returns the witness required to satisfy and spend an anchor input. + * Sets the [`InvoiceRequest::offer_from_hrn`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKWitness build_anchor_input_witness(struct LDKPublicKey funding_key, struct LDKECDSASignature funding_sig); +MUST_USE_RES void InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_sourced_from_human_readable_name(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg, struct LDKHumanReadableName hrn); /** - * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL. */ -void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_obj); +void UnsignedInvoiceRequest_free(struct LDKUnsignedInvoiceRequest this_obj); /** - * Holder public keys + * Creates a copy of the UnsignedInvoiceRequest */ -struct LDKChannelPublicKeys ChannelTransactionParameters_get_holder_pubkeys(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +struct LDKUnsignedInvoiceRequest UnsignedInvoiceRequest_clone(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR orig); /** - * Holder public keys + * Calls the free function if one is set */ -void ChannelTransactionParameters_set_holder_pubkeys(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); +void SignInvoiceRequestFn_free(struct LDKSignInvoiceRequestFn this_ptr); /** - * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + * Returns the [`TaggedHash`] of the invoice to sign. */ -uint16_t ChannelTransactionParameters_get_holder_selected_contest_delay(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTaggedHash UnsignedInvoiceRequest_tagged_hash(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + * Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL. */ -void ChannelTransactionParameters_set_holder_selected_contest_delay(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); +void InvoiceRequest_free(struct LDKInvoiceRequest this_obj); /** - * Whether the holder is the initiator of this channel. - * This is an input to the commitment number obscure factor computation. + * Creates a copy of the InvoiceRequest */ -bool ChannelTransactionParameters_get_is_outbound_from_holder(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +struct LDKInvoiceRequest InvoiceRequest_clone(const struct LDKInvoiceRequest *NONNULL_PTR orig); /** - * Whether the holder is the initiator of this channel. - * This is an input to the commitment number obscure factor computation. + * Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL. */ -void ChannelTransactionParameters_set_is_outbound_from_holder(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, bool val); +void VerifiedInvoiceRequest_free(struct LDKVerifiedInvoiceRequest this_obj); /** - * The late-bound counterparty channel transaction parameters. - * These parameters are populated at the point in the protocol where the counterparty provides them. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. */ -struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +struct LDKOfferId VerifiedInvoiceRequest_get_offer_id(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr); /** - * The late-bound counterparty channel transaction parameters. - * These parameters are populated at the point in the protocol where the counterparty provides them. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. */ -void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKCounterpartyChannelTransactionParameters val); +void VerifiedInvoiceRequest_set_offer_id(struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr, struct LDKOfferId val); /** - * The late-bound funding outpoint - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the VerifiedInvoiceRequest */ -struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +struct LDKVerifiedInvoiceRequest VerifiedInvoiceRequest_clone(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR orig); /** - * The late-bound funding outpoint - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). + * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) + * for the selected chain. */ -void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ UnsignedInvoiceRequest_chains(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * This channel's type, as negotiated during channel open. For old objects where this field - * wasn't serialized, it will default to static_remote_key at deserialization. + * Opaque bytes set by the originator. Useful for authentication and validating fields since it + * is reflected in `invoice_request` messages along with all the other fields from the `offer`. */ -struct LDKChannelTypeFeatures ChannelTransactionParameters_get_channel_type_features(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedInvoiceRequest_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * This channel's type, as negotiated during channel open. For old objects where this field - * wasn't serialized, it will default to static_remote_key at deserialization. + * The minimum amount required for a successful payment of a single item. */ -void ChannelTransactionParameters_set_channel_type_features(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +MUST_USE_RES struct LDKCOption_AmountZ UnsignedInvoiceRequest_amount(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Constructs a new ChannelTransactionParameters given each field + * A complete description of the purpose of the payment. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. * - * Note that counterparty_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None - * Note that funding_outpoint_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg, struct LDKChannelTypeFeatures channel_type_features_arg); +MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_description(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelTransactionParameters + * Features pertaining to the offer. */ -struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); +MUST_USE_RES struct LDKOfferFeatures UnsignedInvoiceRequest_offer_features(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the ChannelTransactionParameters. + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * If `None`, the offer does not expire. */ -uint64_t ChannelTransactionParameters_hash(const struct LDKChannelTransactionParameters *NONNULL_PTR o); +MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_absolute_expiry(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if two ChannelTransactionParameterss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -bool ChannelTransactionParameters_eq(const struct LDKChannelTransactionParameters *NONNULL_PTR a, const struct LDKChannelTransactionParameters *NONNULL_PTR b); +MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_issuer(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_obj); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ UnsignedInvoiceRequest_paths(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Counter-party public keys + * The quantity of items supported. */ -struct LDKChannelPublicKeys CounterpartyChannelTransactionParameters_get_pubkeys(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKQuantity UnsignedInvoiceRequest_supported_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Counter-party public keys + * The public key corresponding to the key used by the recipient to sign invoices. + * - If [`Offer::paths`] is empty, MUST be `Some` and contain the recipient's node id for + * sending an [`InvoiceRequest`]. + * - If [`Offer::paths`] is not empty, MAY be `Some` and contain a transient id. + * - If `None`, the signing pubkey will be the final blinded node id from the + * [`BlindedMessagePath`] in [`Offer::paths`] used to send the [`InvoiceRequest`]. + * + * See also [`Bolt12Invoice::signing_pubkey`]. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice::signing_pubkey`]: crate::offers::invoice::Bolt12Invoice::signing_pubkey + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void CounterpartyChannelTransactionParameters_set_pubkeys(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); +MUST_USE_RES struct LDKPublicKey UnsignedInvoiceRequest_issuer_signing_pubkey(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * The contest delay selected by the counterparty, which applies to holder-broadcast transactions + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_signing_pubkey`]. + * + * [`payer_signing_pubkey`]: Self::payer_signing_pubkey */ -uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKu8slice UnsignedInvoiceRequest_payer_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * The contest delay selected by the counterparty, which applies to holder-broadcast transactions + * A chain from [`Offer::chains`] that the offer is valid for. */ -void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKThirtyTwoBytes UnsignedInvoiceRequest_chain(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Constructs a new CounterpartyChannelTransactionParameters given each field + * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which + * must be greater than or equal to [`Offer::amount`], converted if necessary. + * + * [`chain`]: Self::chain */ -MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); +MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_amount_msats(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the CounterpartyChannelTransactionParameters + * Returns whether an amount was set in the request; otherwise, if [`amount_msats`] is `Some` + * then it was inferred from the [`Offer::amount`] and [`quantity`]. + * + * [`amount_msats`]: Self::amount_msats + * [`quantity`]: Self::quantity */ -struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); +MUST_USE_RES bool UnsignedInvoiceRequest_has_amount_msats(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the CounterpartyChannelTransactionParameters. + * Features pertaining to requesting an invoice. */ -uint64_t CounterpartyChannelTransactionParameters_hash(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR o); +MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedInvoiceRequest_invoice_request_features(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if two CounterpartyChannelTransactionParameterss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -bool CounterpartyChannelTransactionParameters_eq(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR a, const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR b); +MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Whether the late bound parameters are populated. + * A possibly transient pubkey used to sign the invoice request. */ -MUST_USE_RES bool ChannelTransactionParameters_is_populated(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey UnsignedInvoiceRequest_payer_signing_pubkey(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, - * given that the holder is the broadcaster. + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. * - * self.is_populated() must be true before calling this function. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_holder_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_payer_note(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, - * given that the counterparty is the broadcaster. + * If the [`Offer`] was sourced from a BIP 353 Human Readable Name, this should be set by the + * builder to indicate the original [`HumanReadableName`] which was resolved. * - * self.is_populated() must be true before calling this function. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKHumanReadableName UnsignedInvoiceRequest_offer_from_hrn(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read + * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). + * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) + * for the selected chain. */ -struct LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR obj); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ InvoiceRequest_chains(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write + * Opaque bytes set by the originator. Useful for authentication and validating fields since it + * is reflected in `invoice_request` messages along with all the other fields from the `offer`. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ InvoiceRequest_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read + * The minimum amount required for a successful payment of a single item. */ -struct LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *NONNULL_PTR obj); +MUST_USE_RES struct LDKCOption_AmountZ InvoiceRequest_amount(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write + * A complete description of the purpose of the payment. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ ChannelTransactionParameters_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKPrintableString InvoiceRequest_description(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Features pertaining to the offer. */ -void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_obj); +MUST_USE_RES struct LDKOfferFeatures InvoiceRequest_offer_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Get the channel pubkeys for the broadcaster + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * If `None`, the offer does not expire. */ -MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_broadcaster_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_absolute_expiry(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Get the channel pubkeys for the countersignatory + * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_countersignatory_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString InvoiceRequest_issuer(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Get the contest delay applicable to the transactions. - * Note that the contest delay was selected by the countersignatory. + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -MUST_USE_RES uint16_t DirectedChannelTransactionParameters_contest_delay(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ InvoiceRequest_paths(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Whether the channel is outbound from the broadcaster. - * - * The boolean representing the side that initiated the channel is - * an input to the commitment number obscure factor computation. + * The quantity of items supported. */ -MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKQuantity InvoiceRequest_supported_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The funding outpoint + * The public key corresponding to the key used by the recipient to sign invoices. + * - If [`Offer::paths`] is empty, MUST be `Some` and contain the recipient's node id for + * sending an [`InvoiceRequest`]. + * - If [`Offer::paths`] is not empty, MAY be `Some` and contain a transient id. + * - If `None`, the signing pubkey will be the final blinded node id from the + * [`BlindedMessagePath`] in [`Offer::paths`] used to send the [`InvoiceRequest`]. + * + * See also [`Bolt12Invoice::signing_pubkey`]. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice::signing_pubkey`]: crate::offers::invoice::Bolt12Invoice::signing_pubkey + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey InvoiceRequest_issuer_signing_pubkey(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Whether to use anchors for this channel + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_signing_pubkey`]. + * + * [`payer_signing_pubkey`]: Self::payer_signing_pubkey */ -MUST_USE_RES struct LDKChannelTypeFeatures DirectedChannelTransactionParameters_channel_type_features(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKu8slice InvoiceRequest_payer_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. + * A chain from [`Offer::chains`] that the offer is valid for. */ -void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_obj); +MUST_USE_RES struct LDKThirtyTwoBytes InvoiceRequest_chain(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Our counterparty's signature for the transaction + * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which + * must be greater than or equal to [`Offer::amount`], converted if necessary. + * + * [`chain`]: Self::chain */ -struct LDKECDSASignature HolderCommitmentTransaction_get_counterparty_sig(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_amount_msats(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Our counterparty's signature for the transaction + * Returns whether an amount was set in the request; otherwise, if [`amount_msats`] is `Some` + * then it was inferred from the [`Offer::amount`] and [`quantity`]. + * + * [`amount_msats`]: Self::amount_msats + * [`quantity`]: Self::quantity */ -void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +MUST_USE_RES bool InvoiceRequest_has_amount_msats(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * All non-dust counterparty HTLC signatures, in the order they appear in the transaction - * - * Returns a copy of the field. + * Features pertaining to requesting an invoice. */ -struct LDKCVec_ECDSASignatureZ HolderCommitmentTransaction_get_counterparty_htlc_sigs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequest_invoice_request_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * All non-dust counterparty HTLC signatures, in the order they appear in the transaction + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_ECDSASignatureZ val); +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the HolderCommitmentTransaction + * A possibly transient pubkey used to sign the invoice request. */ -struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *NONNULL_PTR orig); +MUST_USE_RES struct LDKPublicKey InvoiceRequest_payer_signing_pubkey(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *NONNULL_PTR obj); +MUST_USE_RES struct LDKPrintableString InvoiceRequest_payer_note(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write + * If the [`Offer`] was sourced from a BIP 353 Human Readable Name, this should be set by the + * builder to indicate the original [`HumanReadableName`] which was resolved. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransaction_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKHumanReadableName InvoiceRequest_offer_from_hrn(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Create a new holder transaction with the given counterparty signatures. - * The funding keys are used to figure out which signature should go first when building the transaction for broadcast. + * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the + * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. + * + * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned + * creation time is used for the `created_at` parameter. + * + * [`Duration`]: core::time::Duration */ -MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKECDSASignature counterparty_sig, struct LDKCVec_ECDSASignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ InvoiceRequest_respond_with(const struct LDKInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); /** - * Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Creates an [`InvoiceBuilder`] for the request with the given required fields. + * + * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after + * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. + *Useful for non-`std` builds where [`std::time::SystemTime`] is not available. + * + * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment + * for the invoice. + * + * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It + * must contain one or more elements ordered from most-preferred to least-preferred, if there's + * a preference. Note, however, that any privacy is lost if a public node id was used for + * [`Offer::issuer_signing_pubkey`]. + * + * Errors if the request contains unknown required features. + * + * # Note + * + * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], + * then first use [`InvoiceRequest::verify_using_metadata`] or + * [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods + * instead. + * + * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at + * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey */ -void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_obj); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ InvoiceRequest_respond_with_no_std(const struct LDKInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); /** - * The commitment transaction + * Verifies that the request was for an offer created using the given key by checking the + * metadata from the offer. + * + * Returns the verified request which contains the derived keys needed to sign a + * [`Bolt12Invoice`] for the request if they could be extracted from the metadata. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -struct LDKTransaction BuiltCommitmentTransaction_get_transaction(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_VerifiedInvoiceRequestNoneZ InvoiceRequest_verify_using_metadata(struct LDKInvoiceRequest this_arg, const struct LDKExpandedKey *NONNULL_PTR key); /** - * The commitment transaction + * Verifies that the request was for an offer created using the given key by checking a nonce + * included with the [`BlindedMessagePath`] for which the request was sent through. + * + * Returns the verified request which contains the derived keys needed to sign a + * [`Bolt12Invoice`] for the request if they could be extracted from the metadata. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKTransaction val); +MUST_USE_RES struct LDKCResult_VerifiedInvoiceRequestNoneZ InvoiceRequest_verify_using_recipient_data(struct LDKInvoiceRequest this_arg, struct LDKNonce nonce, const struct LDKExpandedKey *NONNULL_PTR key); /** - * The txid for the commitment transaction. + * Signature of the invoice request using [`payer_signing_pubkey`]. * - * This is provided as a performance optimization, instead of calling transaction.txid() - * multiple times. + * [`payer_signing_pubkey`]: Self::payer_signing_pubkey */ -const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKSchnorrSignature InvoiceRequest_signature(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The txid for the commitment transaction. - * - * This is provided as a performance optimization, instead of calling transaction.txid() - * multiple times. + * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). + * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) + * for the selected chain. */ -void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ VerifiedInvoiceRequest_chains(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Constructs a new BuiltCommitmentTransaction given each field + * Opaque bytes set by the originator. Useful for authentication and validating fields since it + * is reflected in `invoice_request` messages along with all the other fields from the `offer`. */ -MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ VerifiedInvoiceRequest_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the BuiltCommitmentTransaction + * The minimum amount required for a successful payment of a single item. */ -struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig); +MUST_USE_RES struct LDKCOption_AmountZ VerifiedInvoiceRequest_amount(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read + * A complete description of the purpose of the payment. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj); +MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_description(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write + * Features pertaining to the offer. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKOfferFeatures VerifiedInvoiceRequest_offer_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Get the SIGHASH_ALL sighash value of the transaction. + * Duration since the Unix epoch when an invoice should no longer be requested. * - * This can be used to verify a signature. + * If `None`, the offer does not expire. */ -MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_absolute_expiry(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Signs the counterparty's commitment transaction. + * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKECDSASignature BuiltCommitmentTransaction_sign_counterparty_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_issuer(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Signs the holder commitment transaction because we are about to broadcast it. + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -MUST_USE_RES struct LDKECDSASignature BuiltCommitmentTransaction_sign_holder_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis, const struct LDKEntropySource *NONNULL_PTR entropy_source); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ VerifiedInvoiceRequest_paths(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Frees any resources used by the ClosingTransaction, if is_owned is set and inner is non-NULL. + * The quantity of items supported. */ -void ClosingTransaction_free(struct LDKClosingTransaction this_obj); +MUST_USE_RES struct LDKQuantity VerifiedInvoiceRequest_supported_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the ClosingTransaction + * The public key corresponding to the key used by the recipient to sign invoices. + * - If [`Offer::paths`] is empty, MUST be `Some` and contain the recipient's node id for + * sending an [`InvoiceRequest`]. + * - If [`Offer::paths`] is not empty, MAY be `Some` and contain a transient id. + * - If `None`, the signing pubkey will be the final blinded node id from the + * [`BlindedMessagePath`] in [`Offer::paths`] used to send the [`InvoiceRequest`]. + * + * See also [`Bolt12Invoice::signing_pubkey`]. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice::signing_pubkey`]: crate::offers::invoice::Bolt12Invoice::signing_pubkey + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig); +MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_issuer_signing_pubkey(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the ClosingTransaction. + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_signing_pubkey`]. + * + * [`payer_signing_pubkey`]: Self::payer_signing_pubkey */ -uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o); +MUST_USE_RES struct LDKu8slice VerifiedInvoiceRequest_payer_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if two ClosingTransactions contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * A chain from [`Offer::chains`] that the offer is valid for. */ -bool ClosingTransaction_eq(const struct LDKClosingTransaction *NONNULL_PTR a, const struct LDKClosingTransaction *NONNULL_PTR b); +MUST_USE_RES struct LDKThirtyTwoBytes VerifiedInvoiceRequest_chain(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Construct an object of the class + * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which + * must be greater than or equal to [`Offer::amount`], converted if necessary. + * + * [`chain`]: Self::chain */ -MUST_USE_RES struct LDKClosingTransaction ClosingTransaction_new(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); +MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_amount_msats(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Trust our pre-built transaction. - * - * Applies a wrapper which allows access to the transaction. + * Returns whether an amount was set in the request; otherwise, if [`amount_msats`] is `Some` + * then it was inferred from the [`Offer::amount`] and [`quantity`]. * - * This should only be used if you fully trust the builder of this object. It should not - * be used by an external signer - instead use the verify function. + * [`amount_msats`]: Self::amount_msats + * [`quantity`]: Self::quantity */ -MUST_USE_RES struct LDKTrustedClosingTransaction ClosingTransaction_trust(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool VerifiedInvoiceRequest_has_amount_msats(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Verify our pre-built transaction. - * - * Applies a wrapper which allows access to the transaction. - * - * An external validating signer must call this method before signing - * or using the built transaction. + * Features pertaining to requesting an invoice. */ -MUST_USE_RES struct LDKCResult_TrustedClosingTransactionNoneZ ClosingTransaction_verify(const struct LDKClosingTransaction *NONNULL_PTR this_arg, struct LDKOutPoint funding_outpoint); +MUST_USE_RES struct LDKInvoiceRequestFeatures VerifiedInvoiceRequest_invoice_request_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * The value to be sent to the holder, or zero if the output will be omitted + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -MUST_USE_RES uint64_t ClosingTransaction_to_holder_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * The value to be sent to the counterparty, or zero if the output will be omitted + * A possibly transient pubkey used to sign the invoice request. */ -MUST_USE_RES uint64_t ClosingTransaction_to_counterparty_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_payer_signing_pubkey(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * The destination of the holder's output + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKu8slice ClosingTransaction_to_holder_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_payer_note(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * The destination of the counterparty's output + * If the [`Offer`] was sourced from a BIP 353 Human Readable Name, this should be set by the + * builder to indicate the original [`HumanReadableName`] which was resolved. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKHumanReadableName VerifiedInvoiceRequest_offer_from_hrn(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); + +/** + * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the + * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. + * + * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned + * creation time is used for the `created_at` parameter. + * + * [`Duration`]: core::time::Duration */ -MUST_USE_RES struct LDKu8slice ClosingTransaction_to_counterparty_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_with(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); /** - * Frees any resources used by the TrustedClosingTransaction, if is_owned is set and inner is non-NULL. + * Creates an [`InvoiceBuilder`] for the request with the given required fields. + * + * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after + * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. + *Useful for non-`std` builds where [`std::time::SystemTime`] is not available. + * + * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment + * for the invoice. + * + * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It + * must contain one or more elements ordered from most-preferred to least-preferred, if there's + * a preference. Note, however, that any privacy is lost if a public node id was used for + * [`Offer::issuer_signing_pubkey`]. + * + * Errors if the request contains unknown required features. + * + * # Note + * + * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], + * then first use [`InvoiceRequest::verify_using_metadata`] or + * [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods + * instead. + * + * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at + * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey */ -void TrustedClosingTransaction_free(struct LDKTrustedClosingTransaction this_obj); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_with_no_std(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); /** - * The pre-built Bitcoin commitment transaction + * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses + * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use + * the same [`ExpandedKey`] as the one used to create the offer. + * + * See [`InvoiceRequest::respond_with`] for further details. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -MUST_USE_RES struct LDKTransaction TrustedClosingTransaction_built_transaction(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_using_derived_keys(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); /** - * Get the SIGHASH_ALL sighash value of the transaction. + * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses + * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use + * the same [`ExpandedKey`] as the one used to create the offer. * - * This can be used to verify a signature. + * See [`InvoiceRequest::respond_with_no_std`] for further details. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -MUST_USE_RES struct LDKThirtyTwoBytes TrustedClosingTransaction_get_sighash_all(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +MUST_USE_RES struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_using_derived_keys_no_std(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); /** - * Sign a transaction, either because we are counter-signing the counterparty's transaction or - * because we are about to broadcast a holder transaction. + * Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read */ -MUST_USE_RES struct LDKECDSASignature TrustedClosingTransaction_sign(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +struct LDKCVec_u8Z UnsignedInvoiceRequest_write(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR obj); /** - * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. + * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read */ -void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); +struct LDKCVec_u8Z InvoiceRequest_write(const struct LDKInvoiceRequest *NONNULL_PTR obj); /** - * Creates a copy of the CommitmentTransaction + * Read a InvoiceRequest from a byte array, created by InvoiceRequest_write */ -struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); +struct LDKCResult_InvoiceRequestDecodeErrorZ InvoiceRequest_read(struct LDKu8slice ser); /** - * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read + * Frees any resources used by the InvoiceRequestFields, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *NONNULL_PTR obj); +void InvoiceRequestFields_free(struct LDKInvoiceRequestFields this_obj); /** - * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write + * A possibly transient pubkey used to sign the invoice request. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CommitmentTransaction_read(struct LDKu8slice ser); +struct LDKPublicKey InvoiceRequestFields_get_payer_signing_pubkey(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); /** - * The backwards-counting commitment number + * A possibly transient pubkey used to sign the invoice request. */ -MUST_USE_RES uint64_t CommitmentTransaction_commitment_number(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +void InvoiceRequestFields_set_payer_signing_pubkey(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The per commitment point used by the broadcaster. + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -MUST_USE_RES struct LDKPublicKey CommitmentTransaction_per_commitment_point(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +struct LDKCOption_u64Z InvoiceRequestFields_get_quantity(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); /** - * The value to be sent to the broadcaster + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -MUST_USE_RES uint64_t CommitmentTransaction_to_broadcaster_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +void InvoiceRequestFields_set_quantity(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * The value to be sent to the counterparty + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. Truncated to [`PAYER_NOTE_LIMIT`] characters. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES uint64_t CommitmentTransaction_to_countersignatory_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +struct LDKUntrustedString InvoiceRequestFields_get_payer_note_truncated(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); /** - * The feerate paid per 1000-weight-unit in this commitment transaction. + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. Truncated to [`PAYER_NOTE_LIMIT`] characters. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +void InvoiceRequestFields_set_payer_note_truncated(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKUntrustedString val); /** - * Trust our pre-built transaction and derived transaction creation public keys. - * - * Applies a wrapper which allows access to these fields. + * The Human Readable Name which the sender indicated they were paying to. * - * This should only be used if you fully trust the builder of this object. It should not - * be used by an external signer - instead use the verify function. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +struct LDKHumanReadableName InvoiceRequestFields_get_human_readable_name(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); /** - * Verify our pre-built transaction and derived transaction creation public keys. - * - * Applies a wrapper which allows access to these fields. + * The Human Readable Name which the sender indicated they were paying to. * - * An external validating signer must call this method before signing - * or using the built transaction. + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg, const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); +void InvoiceRequestFields_set_human_readable_name(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKHumanReadableName val); /** - * Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Constructs a new InvoiceRequestFields given each field + * + * Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that human_readable_name_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_obj); +MUST_USE_RES struct LDKInvoiceRequestFields InvoiceRequestFields_new(struct LDKPublicKey payer_signing_pubkey_arg, struct LDKCOption_u64Z quantity_arg, struct LDKUntrustedString payer_note_truncated_arg, struct LDKHumanReadableName human_readable_name_arg); /** - * The transaction ID of the built Bitcoin transaction + * Creates a copy of the InvoiceRequestFields */ -MUST_USE_RES struct LDKThirtyTwoBytes TrustedCommitmentTransaction_txid(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +struct LDKInvoiceRequestFields InvoiceRequestFields_clone(const struct LDKInvoiceRequestFields *NONNULL_PTR orig); /** - * The pre-built Bitcoin commitment transaction + * Checks if two InvoiceRequestFieldss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_built_transaction(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +bool InvoiceRequestFields_eq(const struct LDKInvoiceRequestFields *NONNULL_PTR a, const struct LDKInvoiceRequestFields *NONNULL_PTR b); /** - * The pre-calculated transaction creation public keys. + * Serialize the InvoiceRequestFields object into a byte array which can be read by InvoiceRequestFields_read */ -MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +struct LDKCVec_u8Z InvoiceRequestFields_write(const struct LDKInvoiceRequestFields *NONNULL_PTR obj); /** - * Should anchors be used. + * Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write */ -MUST_USE_RES struct LDKChannelTypeFeatures TrustedCommitmentTransaction_channel_type_features(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ InvoiceRequestFields_read(struct LDKu8slice ser); /** - * Get a signature for each HTLC which was included in the commitment transaction (ie for - * which HTLCOutputInCommitment::transaction_output_index.is_some()). - * - * The returned Vec has one entry for each HTLC, and in the same order. - * - * This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All. + * Frees any resources used by the TaggedHash, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_CVec_ECDSASignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKEntropySource *NONNULL_PTR entropy_source); +void TaggedHash_free(struct LDKTaggedHash this_obj); /** - * Returns the index of the revokeable output, i.e. the `to_local` output sending funds to - * the broadcaster, in the built transaction, if any exists. - * - * There are two cases where this may return `None`: - * - The balance of the revokeable output is below the dust limit (only found on commitments - * early in the channel's lifetime, i.e. before the channel reserve is met). - * - This commitment was created before LDK 0.0.117. In this case, the - * commitment transaction previously didn't contain enough information to locate the - * revokeable output. + * Creates a copy of the TaggedHash */ -MUST_USE_RES struct LDKCOption_usizeZ TrustedCommitmentTransaction_revokeable_output_index(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +struct LDKTaggedHash TaggedHash_clone(const struct LDKTaggedHash *NONNULL_PTR orig); /** - * Helper method to build an unsigned justice transaction spending the revokeable - * `to_local` output to a destination script. Fee estimation accounts for the expected - * revocation witness data that will be added when signed. - * - * This method will error if the given fee rate results in a fee greater than the value - * of the output being spent, or if there exists no revokeable `to_local` output on this - * commitment transaction. See [`Self::revokeable_output_index`] for more details. - * - * The built transaction will allow fee bumping with RBF, and this method takes - * `feerate_per_kw` as an input such that multiple copies of a justice transaction at different - * fee rates may be built. + * Returns the digest to sign. */ -MUST_USE_RES struct LDKCResult_TransactionNoneZ TrustedCommitmentTransaction_build_to_local_justice_tx(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, uint64_t feerate_per_kw, struct LDKCVec_u8Z destination_script); +MUST_USE_RES const uint8_t (*TaggedHash_as_digest(const struct LDKTaggedHash *NONNULL_PTR this_arg))[32]; /** - * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a - * shared secret first. This prevents on-chain observers from discovering how many commitment - * transactions occurred in a channel before it was closed. - * - * This function gets the shared secret from relevant channel public keys and can be used to - * \"decrypt\" the commitment transaction number given a commitment transaction on-chain. + * Returns the tag used in the tagged hash. */ -uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); +MUST_USE_RES struct LDKStr TaggedHash_tag(const struct LDKTaggedHash *NONNULL_PTR this_arg); /** - * Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL. + * Returns the merkle root used in the tagged hash. */ -void ShutdownScript_free(struct LDKShutdownScript this_obj); +MUST_USE_RES struct LDKThirtyTwoBytes TaggedHash_merkle_root(const struct LDKTaggedHash *NONNULL_PTR this_arg); /** - * Creates a copy of the ShutdownScript + * Frees any resources used by the SignError */ -struct LDKShutdownScript ShutdownScript_clone(const struct LDKShutdownScript *NONNULL_PTR orig); +void SignError_free(struct LDKSignError this_ptr); /** - * Checks if two ShutdownScripts contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the SignError */ -bool ShutdownScript_eq(const struct LDKShutdownScript *NONNULL_PTR a, const struct LDKShutdownScript *NONNULL_PTR b); +struct LDKSignError SignError_clone(const struct LDKSignError *NONNULL_PTR orig); /** - * Frees any resources used by the InvalidShutdownScript, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Signing-variant SignError */ -void InvalidShutdownScript_free(struct LDKInvalidShutdownScript this_obj); +struct LDKSignError SignError_signing(void); /** - * The script that did not meet the requirements from [BOLT #2]. - * - * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md + * Utility method to constructs a new Verification-variant SignError */ -struct LDKCVec_u8Z InvalidShutdownScript_get_script(const struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr); +struct LDKSignError SignError_verification(enum LDKSecp256k1Error a); /** - * The script that did not meet the requirements from [BOLT #2]. - * - * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md + * Frees any resources used by the Nonce, if is_owned is set and inner is non-NULL. */ -void InvalidShutdownScript_set_script(struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +void Nonce_free(struct LDKNonce this_obj); /** - * Constructs a new InvalidShutdownScript given each field + * Creates a copy of the Nonce */ -MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg); +struct LDKNonce Nonce_clone(const struct LDKNonce *NONNULL_PTR orig); /** - * Creates a copy of the InvalidShutdownScript + * Checks if two Nonces contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig); +bool Nonce_eq(const struct LDKNonce *NONNULL_PTR a, const struct LDKNonce *NONNULL_PTR b); /** - * Serialize the ShutdownScript object into a byte array which can be read by ShutdownScript_read + * Creates a `Nonce` from the given [`EntropySource`]. */ -struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_PTR obj); +MUST_USE_RES struct LDKNonce Nonce_from_entropy_source(struct LDKEntropySource entropy_source); /** - * Read a ShutdownScript from a byte array, created by ShutdownScript_write + * Returns a slice of the underlying bytes of size [`Nonce::LENGTH`]. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ ShutdownScript_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKu8slice Nonce_as_slice(const struct LDKNonce *NONNULL_PTR this_arg); /** - * Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. + * Serialize the Nonce object into a byte array which can be read by Nonce_read */ -MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wpkh(const uint8_t (*pubkey_hash)[20]); +struct LDKCVec_u8Z Nonce_write(const struct LDKNonce *NONNULL_PTR obj); /** - * Generates a P2WSH script pubkey from the given [`WScriptHash`]. + * Read a Nonce from a byte array, created by Nonce_write */ -MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wsh(const uint8_t (*script_hash)[32]); +struct LDKCResult_NonceDecodeErrorZ Nonce_read(struct LDKu8slice ser); /** - * Generates a witness script pubkey from the given segwit version and program. - * - * Note for version-zero witness scripts you must use [`ShutdownScript::new_p2wpkh`] or - * [`ShutdownScript::new_p2wsh`] instead. - * - * # Errors - * - * This function may return an error if `program` is invalid for the segwit `version`. + * Frees any resources used by the Bolt12ParseError, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ ShutdownScript_new_witness_program(struct LDKWitnessProgram witness_program); +void Bolt12ParseError_free(struct LDKBolt12ParseError this_obj); /** - * Converts the shutdown script into the underlying [`ScriptBuf`]. + * Creates a copy of the Bolt12ParseError */ -MUST_USE_RES struct LDKCVec_u8Z ShutdownScript_into_inner(struct LDKShutdownScript this_arg); +struct LDKBolt12ParseError Bolt12ParseError_clone(const struct LDKBolt12ParseError *NONNULL_PTR orig); /** - * Returns the [`PublicKey`] used for a P2WPKH shutdown script if constructed directly from it. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the Bolt12SemanticError */ -MUST_USE_RES struct LDKPublicKey ShutdownScript_as_legacy_pubkey(const struct LDKShutdownScript *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_clone(const enum LDKBolt12SemanticError *NONNULL_PTR orig); /** - * Returns whether the shutdown script is compatible with the features as defined by BOLT #2. - * - * Specifically, checks for compliance with feature `option_shutdown_anysegwit`. + * Utility method to constructs a new AlreadyExpired-variant Bolt12SemanticError */ -MUST_USE_RES bool ShutdownScript_is_compatible(const struct LDKShutdownScript *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR features); +enum LDKBolt12SemanticError Bolt12SemanticError_already_expired(void); /** - * Get the string representation of a ShutdownScript object + * Utility method to constructs a new UnsupportedChain-variant Bolt12SemanticError */ -struct LDKStr ShutdownScript_to_str(const struct LDKShutdownScript *NONNULL_PTR o); +enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_chain(void); /** - * Frees any resources used by the ChannelId, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new UnexpectedChain-variant Bolt12SemanticError */ -void ChannelId_free(struct LDKChannelId this_obj); - -const uint8_t (*ChannelId_get_a(const struct LDKChannelId *NONNULL_PTR this_ptr))[32]; +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_chain(void); -void ChannelId_set_a(struct LDKChannelId *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * Utility method to constructs a new MissingAmount-variant Bolt12SemanticError + */ +enum LDKBolt12SemanticError Bolt12SemanticError_missing_amount(void); /** - * Constructs a new ChannelId given each field + * Utility method to constructs a new InvalidAmount-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKChannelId ChannelId_new(struct LDKThirtyTwoBytes a_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_amount(void); /** - * Creates a copy of the ChannelId + * Utility method to constructs a new InsufficientAmount-variant Bolt12SemanticError */ -struct LDKChannelId ChannelId_clone(const struct LDKChannelId *NONNULL_PTR orig); +enum LDKBolt12SemanticError Bolt12SemanticError_insufficient_amount(void); /** - * Checks if two ChannelIds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new UnexpectedAmount-variant Bolt12SemanticError */ -bool ChannelId_eq(const struct LDKChannelId *NONNULL_PTR a, const struct LDKChannelId *NONNULL_PTR b); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_amount(void); /** - * Generates a non-cryptographic 64-bit hash of the ChannelId. + * Utility method to constructs a new UnsupportedCurrency-variant Bolt12SemanticError */ -uint64_t ChannelId_hash(const struct LDKChannelId *NONNULL_PTR o); +enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_currency(void); /** - * Create _v1_ channel ID based on a funding TX ID and output index + * Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKChannelId ChannelId_v1_from_funding_txid(const uint8_t (*txid)[32], uint16_t output_index); +enum LDKBolt12SemanticError Bolt12SemanticError_unknown_required_features(void); /** - * Create _v1_ channel ID from a funding tx outpoint + * Utility method to constructs a new UnexpectedFeatures-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKChannelId ChannelId_v1_from_funding_outpoint(struct LDKOutPoint outpoint); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_features(void); /** - * Create a _temporary_ channel ID randomly, based on an entropy source. + * Utility method to constructs a new MissingDescription-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKChannelId ChannelId_temporary_from_entropy_source(const struct LDKEntropySource *NONNULL_PTR entropy_source); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_description(void); /** - * Generic constructor; create a new channel ID from the provided data. - * Use a more specific `*_from_*` constructor when possible. + * Utility method to constructs a new MissingIssuerSigningPubkey-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKChannelId ChannelId_from_bytes(struct LDKThirtyTwoBytes data); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_issuer_signing_pubkey(void); /** - * Create a channel ID consisting of all-zeros data (e.g. when uninitialized or a placeholder). + * Utility method to constructs a new UnexpectedIssuerSigningPubkey-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKChannelId ChannelId_new_zero(void); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_issuer_signing_pubkey(void); /** - * Check whether ID is consisting of all zeros (uninitialized) + * Utility method to constructs a new MissingQuantity-variant Bolt12SemanticError */ -MUST_USE_RES bool ChannelId_is_zero(const struct LDKChannelId *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_quantity(void); /** - * Create _v2_ channel ID by concatenating the holder revocation basepoint with the counterparty - * revocation basepoint and hashing the result. The basepoints will be concatenated in increasing - * sorted order. + * Utility method to constructs a new InvalidQuantity-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKChannelId ChannelId_v2_from_revocation_basepoints(const struct LDKRevocationBasepoint *NONNULL_PTR ours, const struct LDKRevocationBasepoint *NONNULL_PTR theirs); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_quantity(void); /** - * Create temporary _v2_ channel ID by concatenating a zeroed out basepoint with the holder - * revocation basepoint and hashing the result. + * Utility method to constructs a new UnexpectedQuantity-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKChannelId ChannelId_temporary_v2_from_revocation_basepoint(const struct LDKRevocationBasepoint *NONNULL_PTR our_revocation_basepoint); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_quantity(void); /** - * Serialize the ChannelId object into a byte array which can be read by ChannelId_read + * Utility method to constructs a new InvalidMetadata-variant Bolt12SemanticError */ -struct LDKCVec_u8Z ChannelId_write(const struct LDKChannelId *NONNULL_PTR obj); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_metadata(void); /** - * Read a ChannelId from a byte array, created by ChannelId_write + * Utility method to constructs a new UnexpectedMetadata-variant Bolt12SemanticError */ -struct LDKCResult_ChannelIdDecodeErrorZ ChannelId_read(struct LDKu8slice ser); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_metadata(void); /** - * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" - * See [`PhantomKeysManager`] for more information on phantom node payments. - * - * `phantom_route_hints` parameter: - * * Contains channel info for all nodes participating in the phantom invoice - * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each - * participating node - * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is - * updated when a channel becomes disabled or closes - * * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice - * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared - * down - * - * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference - * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). - * If `None` is provided for `payment_hash`, then one will be created. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * `duration_since_epoch` is the current time since epoch in seconds. - * - * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3. - * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block - * confirmations during routing. - * - * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom - * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this - * requirement). - * - * [`PhantomKeysManager`]: crate::sign::PhantomKeysManager - * [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints - * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash - * [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels - * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA - * - *This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller. + * Utility method to constructs a new MissingPayerMetadata-variant Bolt12SemanticError */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_metadata(void); /** - * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" - * See [`PhantomKeysManager`] for more information on phantom node payments. - * - * `phantom_route_hints` parameter: - * * Contains channel info for all nodes participating in the phantom invoice - * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each - * participating node - * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is - * updated when a channel becomes disabled or closes - * * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum - * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected - * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node - * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as - * desired, but note that some nodes will be trimmed if more than 3 nodes are provided. - * - * `description_hash` is a SHA-256 hash of the description text - * - * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference - * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). - * If `None` is provided for `payment_hash`, then one will be created. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * `duration_since_epoch` is the current time since epoch in seconds. - * - * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom - * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this - * requirement). - * - * [`PhantomKeysManager`]: crate::sign::PhantomKeysManager - * [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints - * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash - * [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels - * - *This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller. + * Utility method to constructs a new MissingPayerSigningPubkey-variant Bolt12SemanticError */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ payment_hash, uint32_t invoice_expiry_delta_secs, struct LDKSha256 description_hash, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_signing_pubkey(void); /** - * Utility to construct an invoice. Generally, unless you want to do something like a custom - * cltv_expiry, this is what you should be using to create an invoice. The reason being, this - * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user - * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify - * that the payment secret is valid when the invoice is paid. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block - * confirmations during routing. - * - * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA + * Utility method to constructs a new DuplicatePaymentId-variant Bolt12SemanticError */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +enum LDKBolt12SemanticError Bolt12SemanticError_duplicate_payment_id(void); /** - * Utility to construct an invoice. Generally, unless you want to do something like a custom - * cltv_expiry, this is what you should be using to create an invoice. The reason being, this - * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user - * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify - * that the payment secret is valid when the invoice is paid. - * Use this variant if you want to pass the `description_hash` to the invoice. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block - * confirmations during routing. - * - * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA + * Utility method to constructs a new MissingPaths-variant Bolt12SemanticError */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_paths(void); /** - * See [`create_invoice_from_channelmanager`]. - * - * This version allows for providing custom [`PaymentHash`] and description hash for the invoice. - * - * This may be useful if you're building an on-chain swap or involving another protocol where - * the payment hash is also involved outside the scope of lightning and want to set the - * description hash. + * Utility method to constructs a new UnexpectedPaths-variant Bolt12SemanticError */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_payment_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint32_t invoice_expiry_delta_secs, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_paths(void); /** - * See [`create_invoice_from_channelmanager`]. - * - * This version allows for providing a custom [`PaymentHash`] for the invoice. - * This may be useful if you're building an on-chain swap or involving another protocol where - * the payment hash is also involved outside the scope of lightning. + * Utility method to constructs a new InvalidPayInfo-variant Bolt12SemanticError */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_payment_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_pay_info(void); /** - * Builds the necessary parameters to pay or pre-flight probe the given variable-amount - * (also known as 'zero-amount') [`Bolt11Invoice`] using - * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. - * - * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the - * same [`PaymentHash`] has never been paid before. - * - * Will always succeed unless the invoice has an amount specified, in which case - * [`payment_parameters_from_invoice`] should be used. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes + * Utility method to constructs a new MissingCreationTime-variant Bolt12SemanticError */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_variable_amount_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice, uint64_t amount_msat); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_creation_time(void); /** - * Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using - * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. - * - * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the - * same [`PaymentHash`] has never been paid before. - * - * Will always succeed unless the invoice has no amount specified, in which case - * [`payment_parameters_from_variable_amount_invoice`] should be used. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes + * Utility method to constructs a new MissingPaymentHash-variant Bolt12SemanticError */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payment_hash(void); /** - * Frees any resources used by the Retry + * Utility method to constructs a new UnexpectedPaymentHash-variant Bolt12SemanticError */ -void Retry_free(struct LDKRetry this_ptr); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_payment_hash(void); /** - * Creates a copy of the Retry + * Utility method to constructs a new MissingSigningPubkey-variant Bolt12SemanticError */ -struct LDKRetry Retry_clone(const struct LDKRetry *NONNULL_PTR orig); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_signing_pubkey(void); /** - * Utility method to constructs a new Attempts-variant Retry + * Utility method to constructs a new InvalidSigningPubkey-variant Bolt12SemanticError */ -struct LDKRetry Retry_attempts(uint32_t a); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_signing_pubkey(void); /** - * Utility method to constructs a new Timeout-variant Retry + * Utility method to constructs a new MissingSignature-variant Bolt12SemanticError */ -struct LDKRetry Retry_timeout(uint64_t a); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_signature(void); /** - * Checks if two Retrys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Utility method to constructs a new UnexpectedHumanReadableName-variant Bolt12SemanticError */ -bool Retry_eq(const struct LDKRetry *NONNULL_PTR a, const struct LDKRetry *NONNULL_PTR b); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_human_readable_name(void); /** - * Generates a non-cryptographic 64-bit hash of the Retry. + * Frees any resources used by the RefundMaybeWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. */ -uint64_t Retry_hash(const struct LDKRetry *NONNULL_PTR o); +void RefundMaybeWithDerivedMetadataBuilder_free(struct LDKRefundMaybeWithDerivedMetadataBuilder this_obj); /** - * Serialize the Retry object into a byte array which can be read by Retry_read + * Creates a copy of the RefundMaybeWithDerivedMetadataBuilder */ -struct LDKCVec_u8Z Retry_write(const struct LDKRetry *NONNULL_PTR obj); +struct LDKRefundMaybeWithDerivedMetadataBuilder RefundMaybeWithDerivedMetadataBuilder_clone(const struct LDKRefundMaybeWithDerivedMetadataBuilder *NONNULL_PTR orig); /** - * Read a Retry from a byte array, created by Retry_write + * Creates a new builder for a refund using the `signing_pubkey` for the public node id to send + * to if no [`Refund::paths`] are set. Otherwise, `signing_pubkey` may be a transient pubkey. + * + * Additionally, sets the required (empty) [`Refund::description`], [`Refund::payer_metadata`], + * and [`Refund::amount_msats`]. + * + * # Note + * + * If constructing a [`Refund`] for use with a [`ChannelManager`], use + * [`ChannelManager::create_refund_builder`] instead of [`RefundBuilder::new`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::create_refund_builder`]: crate::ln::channelmanager::ChannelManager::create_refund_builder */ -struct LDKCResult_RetryDecodeErrorZ Retry_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_new(struct LDKCVec_u8Z metadata, struct LDKPublicKey signing_pubkey, uint64_t amount_msats); /** - * Creates a copy of the RetryableSendFailure + * Similar to [`RefundBuilder::new`] except, if [`RefundBuilder::path`] is called, the payer id + * is derived from the given [`ExpandedKey`] and nonce. This provides sender privacy by using a + * different payer id for each refund, assuming a different nonce is used. Otherwise, the + * provided `node_id` is used for the payer id. + * + * Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used by + * [`Bolt12Invoice::verify_using_metadata`] to determine if the invoice was produced for the + * refund given an [`ExpandedKey`]. However, if [`RefundBuilder::path`] is called, then the + * metadata must be included in each [`BlindedMessagePath`] instead. In this case, use + * [`Bolt12Invoice::verify_using_payer_data`]. + * + * The `payment_id` is encrypted in the metadata and should be unique. This ensures that only + * one invoice will be paid for the refund and that payments can be uniquely identified. + * + * [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata + * [`Bolt12Invoice::verify_using_payer_data`]: crate::offers::invoice::Bolt12Invoice::verify_using_payer_data + * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey */ -enum LDKRetryableSendFailure RetryableSendFailure_clone(const enum LDKRetryableSendFailure *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_deriving_signing_pubkey(struct LDKPublicKey node_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce, uint64_t amount_msats, struct LDKThirtyTwoBytes payment_id); /** - * Utility method to constructs a new PaymentExpired-variant RetryableSendFailure + * Sets the [`Refund::description`]. + * + * Successive calls to this method will override the previous setting. */ -enum LDKRetryableSendFailure RetryableSendFailure_payment_expired(void); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_description(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr description); /** - * Utility method to constructs a new RouteNotFound-variant RetryableSendFailure + * Sets the [`Refund::absolute_expiry`] as seconds since the Unix epoch. + *Any expiry that has already passed is valid and can be checked for using [`Refund::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -enum LDKRetryableSendFailure RetryableSendFailure_route_not_found(void); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_absolute_expiry(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, uint64_t absolute_expiry); /** - * Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure + * Sets the [`Refund::issuer`]. + * + * Successive calls to this method will override the previous setting. */ -enum LDKRetryableSendFailure RetryableSendFailure_duplicate_payment(void); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_issuer(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr issuer); /** - * Utility method to constructs a new OnionPacketSizeExceeded-variant RetryableSendFailure + * Adds a blinded path to [`Refund::paths`]. Must include at least one path if only connected + * by private channels or if [`Refund::payer_signing_pubkey`] is not a public node id. + * + * Successive calls to this method will add another blinded path. Caller is responsible for not + * adding duplicate paths. */ -enum LDKRetryableSendFailure RetryableSendFailure_onion_packet_size_exceeded(void); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_path(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKBlindedMessagePath path); /** - * Checks if two RetryableSendFailures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Sets the [`Refund::chain`] of the given [`Network`] for paying an invoice. If not + * called, [`Network::Bitcoin`] is assumed. + * + * Successive calls to this method will override the previous setting. */ -bool RetryableSendFailure_eq(const enum LDKRetryableSendFailure *NONNULL_PTR a, const enum LDKRetryableSendFailure *NONNULL_PTR b); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_chain(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, enum LDKNetwork network); /** - * Frees any resources used by the Bolt12PaymentError + * Sets [`Refund::quantity`] of items. This is purely for informational purposes. It is useful + * when the refund pertains to a [`Bolt12Invoice`] that paid for more than one item from an + * [`Offer`] as specified by [`InvoiceRequest::quantity`]. + * + * Successive calls to this method will override the previous setting. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity + * [`Offer`]: crate::offers::offer::Offer */ -void Bolt12PaymentError_free(struct LDKBolt12PaymentError this_ptr); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_quantity(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, uint64_t quantity); /** - * Creates a copy of the Bolt12PaymentError + * Sets the [`Refund::payer_note`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKBolt12PaymentError Bolt12PaymentError_clone(const struct LDKBolt12PaymentError *NONNULL_PTR orig); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_payer_note(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr payer_note); /** - * Utility method to constructs a new UnexpectedInvoice-variant Bolt12PaymentError + * Builds a [`Refund`] after checking for valid semantics. */ -struct LDKBolt12PaymentError Bolt12PaymentError_unexpected_invoice(void); +MUST_USE_RES struct LDKCResult_RefundBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_build(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg); /** - * Utility method to constructs a new DuplicateInvoice-variant Bolt12PaymentError + * Frees any resources used by the Refund, if is_owned is set and inner is non-NULL. */ -struct LDKBolt12PaymentError Bolt12PaymentError_duplicate_invoice(void); +void Refund_free(struct LDKRefund this_obj); /** - * Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12PaymentError + * Creates a copy of the Refund */ -struct LDKBolt12PaymentError Bolt12PaymentError_unknown_required_features(void); +struct LDKRefund Refund_clone(const struct LDKRefund *NONNULL_PTR orig); /** - * Utility method to constructs a new SendingFailed-variant Bolt12PaymentError + * A complete description of the purpose of the refund. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. */ -struct LDKBolt12PaymentError Bolt12PaymentError_sending_failed(enum LDKRetryableSendFailure a); +MUST_USE_RES struct LDKPrintableString Refund_description(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if two Bolt12PaymentErrors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Duration since the Unix epoch when an invoice should no longer be sent. + * + * If `None`, the refund does not expire. */ -bool Bolt12PaymentError_eq(const struct LDKBolt12PaymentError *NONNULL_PTR a, const struct LDKBolt12PaymentError *NONNULL_PTR b); +MUST_USE_RES struct LDKCOption_u64Z Refund_absolute_expiry(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Frees any resources used by the ProbeSendFailure + * Whether the refund has expired. */ -void ProbeSendFailure_free(struct LDKProbeSendFailure this_ptr); +MUST_USE_RES bool Refund_is_expired(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Creates a copy of the ProbeSendFailure + * Whether the refund has expired given the duration since the Unix epoch. */ -struct LDKProbeSendFailure ProbeSendFailure_clone(const struct LDKProbeSendFailure *NONNULL_PTR orig); +MUST_USE_RES bool Refund_is_expired_no_std(const struct LDKRefund *NONNULL_PTR this_arg, uint64_t duration_since_epoch); /** - * Utility method to constructs a new RouteNotFound-variant ProbeSendFailure + * The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKProbeSendFailure ProbeSendFailure_route_not_found(void); +MUST_USE_RES struct LDKPrintableString Refund_issuer(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ParameterError-variant ProbeSendFailure + * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender + * privacy by obfuscating its node id. */ -struct LDKProbeSendFailure ProbeSendFailure_parameter_error(struct LDKAPIError a); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Refund_paths(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Utility method to constructs a new DuplicateProbe-variant ProbeSendFailure + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_signing_pubkey`]. + * + * [`payer_signing_pubkey`]: Self::payer_signing_pubkey */ -struct LDKProbeSendFailure ProbeSendFailure_duplicate_probe(void); +MUST_USE_RES struct LDKu8slice Refund_payer_metadata(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if two ProbeSendFailures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * A chain that the refund is valid for. */ -bool ProbeSendFailure_eq(const struct LDKProbeSendFailure *NONNULL_PTR a, const struct LDKProbeSendFailure *NONNULL_PTR b); +MUST_USE_RES struct LDKThirtyTwoBytes Refund_chain(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Frees any resources used by the RecipientOnionFields, if is_owned is set and inner is non-NULL. + * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]). + * + * [`chain`]: Self::chain */ -void RecipientOnionFields_free(struct LDKRecipientOnionFields this_obj); +MUST_USE_RES uint64_t Refund_amount_msats(const struct LDKRefund *NONNULL_PTR this_arg); /** - * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat - * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to - * authenticate the sender to the recipient and prevent payment-probing (deanonymization) - * attacks. - * - * If you do not have one, the [`Route`] you pay over must not contain multiple paths as - * multi-path payments require a recipient-provided secret. - * - * Some implementations may reject spontaneous payments with payment secrets, so you may only - * want to provide a secret for a spontaneous payment if MPP is needed and you know your - * recipient will not reject it. + * Features pertaining to requesting an invoice. */ -struct LDKCOption_ThirtyTwoBytesZ RecipientOnionFields_get_payment_secret(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInvoiceRequestFeatures Refund_features(const struct LDKRefund *NONNULL_PTR this_arg); /** - * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat - * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to - * authenticate the sender to the recipient and prevent payment-probing (deanonymization) - * attacks. - * - * If you do not have one, the [`Route`] you pay over must not contain multiple paths as - * multi-path payments require a recipient-provided secret. - * - * Some implementations may reject spontaneous payments with payment secrets, so you may only - * want to provide a secret for a spontaneous payment if MPP is needed and you know your - * recipient will not reject it. + * The quantity of an item that refund is for. */ -void RecipientOnionFields_set_payment_secret(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); +MUST_USE_RES struct LDKCOption_u64Z Refund_quantity(const struct LDKRefund *NONNULL_PTR this_arg); /** - * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of - * arbitrary length. This gives recipients substantially more flexibility to receive - * additional data. - * - * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication - * scheme to authenticate received payments against expected payments and invoices, this field - * is not used in LDK for received payments, and can be used to store arbitrary data in - * invoices which will be received with the payment. - * - * Note that this field was added to the lightning specification more recently than - * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata - * may not be supported as universally. + * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly + * transient pubkey. * - * Returns a copy of the field. + * [`paths`]: Self::paths */ -struct LDKCOption_CVec_u8ZZ RecipientOnionFields_get_payment_metadata(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPublicKey Refund_payer_signing_pubkey(const struct LDKRefund *NONNULL_PTR this_arg); /** - * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of - * arbitrary length. This gives recipients substantially more flexibility to receive - * additional data. - * - * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication - * scheme to authenticate received payments against expected payments and invoices, this field - * is not used in LDK for received payments, and can be used to store arbitrary data in - * invoices which will be received with the payment. + * Payer provided note to include in the invoice. * - * Note that this field was added to the lightning specification more recently than - * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata - * may not be supported as universally. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void RecipientOnionFields_set_payment_metadata(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +MUST_USE_RES struct LDKPrintableString Refund_payer_note(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Creates a copy of the RecipientOnionFields + * Generates a non-cryptographic 64-bit hash of the Refund. */ -struct LDKRecipientOnionFields RecipientOnionFields_clone(const struct LDKRecipientOnionFields *NONNULL_PTR orig); +uint64_t Refund_hash(const struct LDKRefund *NONNULL_PTR o); /** - * Checks if two RecipientOnionFieldss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a Refund from a byte array, created by Refund_write */ -bool RecipientOnionFields_eq(const struct LDKRecipientOnionFields *NONNULL_PTR a, const struct LDKRecipientOnionFields *NONNULL_PTR b); +struct LDKCResult_RefundDecodeErrorZ Refund_read(struct LDKu8slice ser); /** - * Serialize the RecipientOnionFields object into a byte array which can be read by RecipientOnionFields_read + * Serialize the Refund object into a byte array which can be read by Refund_read */ -struct LDKCVec_u8Z RecipientOnionFields_write(const struct LDKRecipientOnionFields *NONNULL_PTR obj); +struct LDKCVec_u8Z Refund_write(const struct LDKRefund *NONNULL_PTR obj); /** - * Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write + * Read a Refund object from a string */ -struct LDKCResult_RecipientOnionFieldsDecodeErrorZ RecipientOnionFields_read(struct LDKu8slice ser); +struct LDKCResult_RefundBolt12ParseErrorZ Refund_from_str(struct LDKStr s); /** - * Creates a [`RecipientOnionFields`] from only a [`PaymentSecret`]. This is the most common - * set of onion fields for today's BOLT11 invoices - most nodes require a [`PaymentSecret`] - * but do not require or provide any further data. + * Get the string representation of a Refund object */ -MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_secret_only(struct LDKThirtyTwoBytes payment_secret); +struct LDKStr Refund_to_str(const struct LDKRefund *NONNULL_PTR o); /** - * Creates a new [`RecipientOnionFields`] with no fields. This generally does not create - * payable HTLCs except for single-path spontaneous payments, i.e. this should generally - * only be used for calls to [`ChannelManager::send_spontaneous_payment`]. If you are sending - * a spontaneous MPP this will not work as all MPP require payment secrets; you may - * instead want to use [`RecipientOnionFields::secret_only`]. - * - * [`ChannelManager::send_spontaneous_payment`]: super::channelmanager::ChannelManager::send_spontaneous_payment - * [`RecipientOnionFields::secret_only`]: RecipientOnionFields::secret_only + * Creates a copy of the UtxoLookupError */ -MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_spontaneous_empty(void); +enum LDKUtxoLookupError UtxoLookupError_clone(const enum LDKUtxoLookupError *NONNULL_PTR orig); /** - * Creates a new [`RecipientOnionFields`] from an existing one, adding custom TLVs. Each - * TLV is provided as a `(u64, Vec)` for the type number and serialized value - * respectively. TLV type numbers must be unique and within the range - * reserved for custom types, i.e. >= 2^16, otherwise this method will return `Err(())`. - * - * This method will also error for types in the experimental range which have been - * standardized within the protocol, which only includes 5482373484 (keysend) for now. - * - * See [`Self::custom_tlvs`] for more info. + * Utility method to constructs a new UnknownChain-variant UtxoLookupError */ -MUST_USE_RES struct LDKCResult_RecipientOnionFieldsNoneZ RecipientOnionFields_with_custom_tlvs(struct LDKRecipientOnionFields this_arg, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs); +enum LDKUtxoLookupError UtxoLookupError_unknown_chain(void); /** - * Gets the custom TLVs that will be sent or have been received. - * - * Custom TLVs allow sending extra application-specific data with a payment. They provide - * additional flexibility on top of payment metadata, as while other implementations may - * require `payment_metadata` to reflect metadata provided in an invoice, custom TLVs - * do not have this restriction. - * - * Note that if this field is non-empty, it will contain strictly increasing TLVs, each - * represented by a `(u64, Vec)` for its type number and serialized value respectively. - * This is validated when setting this field using [`Self::with_custom_tlvs`]. + * Utility method to constructs a new UnknownTx-variant UtxoLookupError */ -MUST_USE_RES struct LDKCVec_C2Tuple_u64CVec_u8ZZZ RecipientOnionFields_custom_tlvs(const struct LDKRecipientOnionFields *NONNULL_PTR this_arg); +enum LDKUtxoLookupError UtxoLookupError_unknown_tx(void); /** - * Calls the free function if one is set + * Frees any resources used by the UtxoResult */ -void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); +void UtxoResult_free(struct LDKUtxoResult this_ptr); /** - * Creates a copy of a Type + * Creates a copy of the UtxoResult */ -struct LDKType Type_clone(const struct LDKType *NONNULL_PTR orig); +struct LDKUtxoResult UtxoResult_clone(const struct LDKUtxoResult *NONNULL_PTR orig); /** - * Calls the free function if one is set + * Utility method to constructs a new Sync-variant UtxoResult */ -void Type_free(struct LDKType this_ptr); +struct LDKUtxoResult UtxoResult_sync(struct LDKCResult_TxOutUtxoLookupErrorZ a); /** - * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read + * Utility method to constructs a new Async-variant UtxoResult */ -struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); +struct LDKUtxoResult UtxoResult_async(struct LDKUtxoFuture a); /** - * Read a InitFeatures from a byte array, created by InitFeatures_write + * Calls the free function if one is set */ -struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); +void UtxoLookup_free(struct LDKUtxoLookup this_ptr); /** - * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read + * Frees any resources used by the UtxoFuture, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); +void UtxoFuture_free(struct LDKUtxoFuture this_obj); /** - * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write + * Creates a copy of the UtxoFuture */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); +struct LDKUtxoFuture UtxoFuture_clone(const struct LDKUtxoFuture *NONNULL_PTR orig); /** - * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read + * Builds a new future for later resolution. */ -struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKUtxoFuture UtxoFuture_new(void); /** - * Read a NodeFeatures from a byte array, created by NodeFeatures_write + * Resolves this future against the given `graph` and with the given `result`. + * + * This is identical to calling [`UtxoFuture::resolve`] with a dummy `gossip`, disabling + * forwarding the validated gossip message onwards to peers. + * + * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order + * to allow us to interact with peers again, you should call [`PeerManager::process_events`] + * after this. + * + * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high + * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events */ -struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); +void UtxoFuture_resolve_without_forwarding(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, struct LDKCResult_TxOutUtxoLookupErrorZ result); /** - * Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read + * Resolves this future against the given `graph` and with the given `result`. + * + * The given `gossip` is used to broadcast any validated messages onwards to all peers which + * have available buffer space. + * + * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order + * to allow us to interact with peers again, you should call [`PeerManager::process_events`] + * after this. + * + * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high + * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events */ -struct LDKCVec_u8Z Bolt11InvoiceFeatures_write(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR obj); +void UtxoFuture_resolve(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, const struct LDKP2PGossipSync *NONNULL_PTR gossip, struct LDKCResult_TxOutUtxoLookupErrorZ result); /** - * Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write + * Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ Bolt11InvoiceFeatures_read(struct LDKu8slice ser); +void NodeId_free(struct LDKNodeId this_obj); /** - * Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read + * Creates a copy of the NodeId */ -struct LDKCVec_u8Z Bolt12InvoiceFeatures_write(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR obj); +struct LDKNodeId NodeId_clone(const struct LDKNodeId *NONNULL_PTR orig); /** - * Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write + * Checks if two NodeIds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ Bolt12InvoiceFeatures_read(struct LDKu8slice ser); +bool NodeId_eq(const struct LDKNodeId *NONNULL_PTR a, const struct LDKNodeId *NONNULL_PTR b); /** - * Serialize the BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read + * Create a new NodeId from a public key */ -struct LDKCVec_u8Z BlindedHopFeatures_write(const struct LDKBlindedHopFeatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKNodeId NodeId_from_pubkey(struct LDKPublicKey pubkey); /** - * Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write + * Create a new NodeId from a slice of bytes */ -struct LDKCResult_BlindedHopFeaturesDecodeErrorZ BlindedHopFeatures_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_NodeIdDecodeErrorZ NodeId_from_slice(struct LDKu8slice bytes); /** - * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read + * Get the public key slice from this NodeId */ -struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKu8slice NodeId_as_slice(const struct LDKNodeId *NONNULL_PTR this_arg); /** - * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write + * Get the public key as an array from this NodeId */ -struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser); +MUST_USE_RES const uint8_t (*NodeId_as_array(const struct LDKNodeId *NONNULL_PTR this_arg))[33]; /** - * Frees any resources used by the OfferId, if is_owned is set and inner is non-NULL. + * Get the public key from this NodeId */ -void OfferId_free(struct LDKOfferId this_obj); +MUST_USE_RES struct LDKCResult_PublicKeySecp256k1ErrorZ NodeId_as_pubkey(const struct LDKNodeId *NONNULL_PTR this_arg); -const uint8_t (*OfferId_get_a(const struct LDKOfferId *NONNULL_PTR this_ptr))[32]; +/** + * Get the string representation of a NodeId object + */ +struct LDKStr NodeId_to_str(const struct LDKNodeId *NONNULL_PTR o); -void OfferId_set_a(struct LDKOfferId *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * Generates a non-cryptographic 64-bit hash of the NodeId. + */ +uint64_t NodeId_hash(const struct LDKNodeId *NONNULL_PTR o); /** - * Constructs a new OfferId given each field + * Serialize the NodeId object into a byte array which can be read by NodeId_read */ -MUST_USE_RES struct LDKOfferId OfferId_new(struct LDKThirtyTwoBytes a_arg); +struct LDKCVec_u8Z NodeId_write(const struct LDKNodeId *NONNULL_PTR obj); /** - * Creates a copy of the OfferId + * Read a NodeId from a byte array, created by NodeId_write */ -struct LDKOfferId OfferId_clone(const struct LDKOfferId *NONNULL_PTR orig); +struct LDKCResult_NodeIdDecodeErrorZ NodeId_read(struct LDKu8slice ser); /** - * Checks if two OfferIds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. */ -bool OfferId_eq(const struct LDKOfferId *NONNULL_PTR a, const struct LDKOfferId *NONNULL_PTR b); +void NetworkGraph_free(struct LDKNetworkGraph this_obj); /** - * Serialize the OfferId object into a byte array which can be read by OfferId_read + * Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z OfferId_write(const struct LDKOfferId *NONNULL_PTR obj); +void ReadOnlyNetworkGraph_free(struct LDKReadOnlyNetworkGraph this_obj); /** - * Read a OfferId from a byte array, created by OfferId_write + * Frees any resources used by the NetworkUpdate */ -struct LDKCResult_OfferIdDecodeErrorZ OfferId_read(struct LDKu8slice ser); +void NetworkUpdate_free(struct LDKNetworkUpdate this_ptr); /** - * Frees any resources used by the OfferWithExplicitMetadataBuilder, if is_owned is set and inner is non-NULL. + * Creates a copy of the NetworkUpdate */ -void OfferWithExplicitMetadataBuilder_free(struct LDKOfferWithExplicitMetadataBuilder this_obj); +struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNULL_PTR orig); /** - * Creates a copy of the OfferWithExplicitMetadataBuilder + * Utility method to constructs a new ChannelFailure-variant NetworkUpdate */ -struct LDKOfferWithExplicitMetadataBuilder OfferWithExplicitMetadataBuilder_clone(const struct LDKOfferWithExplicitMetadataBuilder *NONNULL_PTR orig); +struct LDKNetworkUpdate NetworkUpdate_channel_failure(uint64_t short_channel_id, bool is_permanent); /** - * Frees any resources used by the OfferWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new NodeFailure-variant NetworkUpdate */ -void OfferWithDerivedMetadataBuilder_free(struct LDKOfferWithDerivedMetadataBuilder this_obj); +struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); /** - * Creates a copy of the OfferWithDerivedMetadataBuilder + * Checks if two NetworkUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKOfferWithDerivedMetadataBuilder OfferWithDerivedMetadataBuilder_clone(const struct LDKOfferWithDerivedMetadataBuilder *NONNULL_PTR orig); +bool NetworkUpdate_eq(const struct LDKNetworkUpdate *NONNULL_PTR a, const struct LDKNetworkUpdate *NONNULL_PTR b); /** - * Creates a new builder for an offer using the `signing_pubkey` for signing invoices. The - * associated secret key must be remembered while the offer is valid. - * - * Use a different pubkey per offer to avoid correlating offers. - * - * # Note - * - * If constructing an [`Offer`] for use with a [`ChannelManager`], use - * [`ChannelManager::create_offer_builder`] instead of [`OfferBuilder::new`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder + * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read */ -MUST_USE_RES struct LDKOfferWithExplicitMetadataBuilder OfferWithExplicitMetadataBuilder_new(struct LDKPublicKey signing_pubkey); +struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj); /** - * Sets the [`Offer::metadata`] to the given bytes. - * - * Successive calls to this method will override the previous setting. + * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ OfferWithExplicitMetadataBuilder_metadata(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKCVec_u8Z metadata); +struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(struct LDKu8slice ser); /** - * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, - * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. - * - * See [`Offer::chains`] on how this relates to the payment currency. - * - * Successive calls to this method will add another chain hash. + * Frees any resources used by the P2PGossipSync, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_chain(struct LDKOfferWithExplicitMetadataBuilder this_arg, enum LDKNetwork network); +void P2PGossipSync_free(struct LDKP2PGossipSync this_obj); /** - * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. - * - * Successive calls to this method will override the previous setting. + * Creates a new tracker of the actual state of the network of channels and nodes, + * assuming an existing [`NetworkGraph`]. + * UTXO lookup is used to make sure announced channels exist on-chain, channel data is + * correct, and the announcement is signed with channel owners' keys. */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_amount_msats(struct LDKOfferWithExplicitMetadataBuilder this_arg, uint64_t amount_msats); +MUST_USE_RES struct LDKP2PGossipSync P2PGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCOption_UtxoLookupZ utxo_lookup, struct LDKLogger logger); /** - * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. - *Any expiry that has already passed is valid and can be checked for using [`Offer::is_expired`]. - * - * Successive calls to this method will override the previous setting. + * Adds a provider used to check new announcements. Does not affect + * existing announcements unless they are updated. + * Add, update or remove the provider would replace the current one. */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_absolute_expiry(struct LDKOfferWithExplicitMetadataBuilder this_arg, uint64_t absolute_expiry); +void P2PGossipSync_add_utxo_lookup(const struct LDKP2PGossipSync *NONNULL_PTR this_arg, struct LDKCOption_UtxoLookupZ utxo_lookup); /** - * Sets the [`Offer::description`]. + * Handles any network updates originating from [`Event`]s. * - * Successive calls to this method will override the previous setting. + * [`Event`]: crate::events::Event */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_description(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKStr description); +void NetworkGraph_handle_network_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNetworkUpdate *NONNULL_PTR network_update); /** - * Sets the [`Offer::issuer`]. - * - * Successive calls to this method will override the previous setting. + * Gets the chain hash for this network graph. */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_issuer(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKStr issuer); +MUST_USE_RES struct LDKThirtyTwoBytes NetworkGraph_get_chain_hash(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by - * private channels or if [`Offer::issuer_signing_pubkey`] is not a public node id. + * Verifies the signature of a [`NodeAnnouncement`]. * - * Successive calls to this method will add another blinded path. Caller is responsible for not - * adding duplicate paths. + * Returns an error if it is invalid. */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_path(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKBlindedMessagePath path); +struct LDKCResult_NoneLightningErrorZ verify_node_announcement(const struct LDKNodeAnnouncement *NONNULL_PTR msg); /** - * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to - * [`Quantity::One`]. + * Verifies all signatures included in a [`ChannelAnnouncement`]. * - * Successive calls to this method will override the previous setting. + * Returns an error if one of the signatures is invalid. */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_supported_quantity(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKQuantity quantity); +struct LDKCResult_NoneLightningErrorZ verify_channel_announcement(const struct LDKChannelAnnouncement *NONNULL_PTR msg); /** - * Builds an [`Offer`] from the builder's settings. + * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is */ -MUST_USE_RES struct LDKCResult_OfferBolt12SemanticErrorZ OfferWithExplicitMetadataBuilder_build(struct LDKOfferWithExplicitMetadataBuilder this_arg); +struct LDKRoutingMessageHandler P2PGossipSync_as_RoutingMessageHandler(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); /** - * Similar to [`OfferBuilder::new`] except, if [`OfferBuilder::path`] is called, the signing - * pubkey is derived from the given [`ExpandedKey`] and [`Nonce`]. This provides recipient - * privacy by using a different signing pubkey for each offer. Otherwise, the provided - * `node_id` is used for [`Offer::issuer_signing_pubkey`]. - * - * Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by - * [`InvoiceRequest::verify_using_metadata`] to determine if the request was produced for the - * offer given an [`ExpandedKey`]. However, if [`OfferBuilder::path`] is called, then the - * metadata will not be set and must be included in each [`BlindedMessagePath`] instead. In this case, - * use [`InvoiceRequest::verify_using_recipient_data`]. - * - * [`InvoiceRequest::verify_using_metadata`]: crate::offers::invoice_request::InvoiceRequest::verify_using_metadata - * [`InvoiceRequest::verify_using_recipient_data`]: crate::offers::invoice_request::InvoiceRequest::verify_using_recipient_data - * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -MUST_USE_RES struct LDKOfferWithDerivedMetadataBuilder OfferWithDerivedMetadataBuilder_deriving_signing_pubkey(struct LDKPublicKey node_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce); +struct LDKMessageSendEventsProvider P2PGossipSync_as_MessageSendEventsProvider(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); /** - * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, - * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. - * - * See [`Offer::chains`] on how this relates to the payment currency. - * - * Successive calls to this method will add another chain hash. + * Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_chain(struct LDKOfferWithDerivedMetadataBuilder this_arg, enum LDKNetwork network); +void ChannelUpdateInfo_free(struct LDKChannelUpdateInfo this_obj); /** - * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. - * - * Successive calls to this method will override the previous setting. + * The minimum value, which must be relayed to the next hop via the channel */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_amount_msats(struct LDKOfferWithDerivedMetadataBuilder this_arg, uint64_t amount_msats); +uint64_t ChannelUpdateInfo_get_htlc_minimum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. - *Any expiry that has already passed is valid and can be checked for using [`Offer::is_expired`]. - * - * Successive calls to this method will override the previous setting. + * The minimum value, which must be relayed to the next hop via the channel */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_absolute_expiry(struct LDKOfferWithDerivedMetadataBuilder this_arg, uint64_t absolute_expiry); +void ChannelUpdateInfo_set_htlc_minimum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Sets the [`Offer::description`]. - * - * Successive calls to this method will override the previous setting. + * The maximum value which may be relayed to the next hop via the channel. */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_description(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKStr description); +uint64_t ChannelUpdateInfo_get_htlc_maximum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Sets the [`Offer::issuer`]. - * - * Successive calls to this method will override the previous setting. + * The maximum value which may be relayed to the next hop via the channel. */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_issuer(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKStr issuer); +void ChannelUpdateInfo_set_htlc_maximum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by - * private channels or if [`Offer::issuer_signing_pubkey`] is not a public node id. - * - * Successive calls to this method will add another blinded path. Caller is responsible for not - * adding duplicate paths. + * Fees charged when the channel is used for routing */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_path(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKBlindedMessagePath path); +struct LDKRoutingFees ChannelUpdateInfo_get_fees(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to - * [`Quantity::One`]. - * - * Successive calls to this method will override the previous setting. + * Fees charged when the channel is used for routing */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_supported_quantity(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKQuantity quantity); +void ChannelUpdateInfo_set_fees(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** - * Builds an [`Offer`] from the builder's settings. + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES struct LDKCResult_OfferBolt12SemanticErrorZ OfferWithDerivedMetadataBuilder_build(struct LDKOfferWithDerivedMetadataBuilder this_arg); +uint32_t ChannelUpdateInfo_get_last_update(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Offer, if is_owned is set and inner is non-NULL. + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. */ -void Offer_free(struct LDKOffer this_obj); +void ChannelUpdateInfo_set_last_update(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a copy of the Offer + * The difference in CLTV values that you must have when routing through this channel. */ -struct LDKOffer Offer_clone(const struct LDKOffer *NONNULL_PTR orig); +uint16_t ChannelUpdateInfo_get_cltv_expiry_delta(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). - * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) - * for the selected chain. + * The difference in CLTV values that you must have when routing through this channel. */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ Offer_chains(const struct LDKOffer *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_cltv_expiry_delta(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint16_t val); /** - * Opaque bytes set by the originator. Useful for authentication and validating fields since it - * is reflected in `invoice_request` messages along with all the other fields from the `offer`. + * Whether the channel can be currently used for payments (in this one direction). */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ Offer_metadata(const struct LDKOffer *NONNULL_PTR this_arg); +bool ChannelUpdateInfo_get_enabled(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * The minimum amount required for a successful payment of a single item. + * Whether the channel can be currently used for payments (in this one direction). */ -MUST_USE_RES struct LDKCOption_AmountZ Offer_amount(const struct LDKOffer *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_enabled(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, bool val); /** - * A complete description of the purpose of the payment. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. + * Most recent update for the channel received from the network + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKPrintableString Offer_description(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKChannelUpdate ChannelUpdateInfo_get_last_update_message(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Features pertaining to the offer. + * Most recent update for the channel received from the network + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKOfferFeatures Offer_offer_features(const struct LDKOffer *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_last_update_message(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); /** - * Duration since the Unix epoch when an invoice should no longer be requested. + * Constructs a new ChannelUpdateInfo given each field * - * If `None`, the offer does not expire. + * Note that last_update_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCOption_u64Z Offer_absolute_expiry(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelUpdateInfo ChannelUpdateInfo_new(uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, uint32_t last_update_arg, uint16_t cltv_expiry_delta_arg, bool enabled_arg, struct LDKChannelUpdate last_update_message_arg); /** - * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the ChannelUpdateInfo */ -MUST_USE_RES struct LDKPrintableString Offer_issuer(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKChannelUpdateInfo ChannelUpdateInfo_clone(const struct LDKChannelUpdateInfo *NONNULL_PTR orig); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * Checks if two ChannelUpdateInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Offer_paths(const struct LDKOffer *NONNULL_PTR this_arg); +bool ChannelUpdateInfo_eq(const struct LDKChannelUpdateInfo *NONNULL_PTR a, const struct LDKChannelUpdateInfo *NONNULL_PTR b); /** - * The quantity of items supported. + * Get the string representation of a ChannelUpdateInfo object */ -MUST_USE_RES struct LDKQuantity Offer_supported_quantity(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKStr ChannelUpdateInfo_to_str(const struct LDKChannelUpdateInfo *NONNULL_PTR o); /** - * The public key corresponding to the key used by the recipient to sign invoices. - * - If [`Offer::paths`] is empty, MUST be `Some` and contain the recipient's node id for - * sending an [`InvoiceRequest`]. - * - If [`Offer::paths`] is not empty, MAY be `Some` and contain a transient id. - * - If `None`, the signing pubkey will be the final blinded node id from the - * [`BlindedMessagePath`] in [`Offer::paths`] used to send the [`InvoiceRequest`]. - * - * See also [`Bolt12Invoice::signing_pubkey`]. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice::signing_pubkey`]: crate::offers::invoice::Bolt12Invoice::signing_pubkey - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read */ -MUST_USE_RES struct LDKPublicKey Offer_issuer_signing_pubkey(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKCVec_u8Z ChannelUpdateInfo_write(const struct LDKChannelUpdateInfo *NONNULL_PTR obj); /** - * Returns the id of the offer. + * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write */ -MUST_USE_RES struct LDKOfferId Offer_id(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ ChannelUpdateInfo_read(struct LDKu8slice ser); /** - * Returns whether the given chain is supported by the offer. + * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool Offer_supports_chain(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes chain); +void ChannelInfo_free(struct LDKChannelInfo this_obj); /** - * Whether the offer has expired. + * Protocol features of a channel communicated during its announcement */ -MUST_USE_RES bool Offer_is_expired(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKChannelFeatures ChannelInfo_get_features(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Whether the offer has expired given the duration since the Unix epoch. + * Protocol features of a channel communicated during its announcement */ -MUST_USE_RES bool Offer_is_expired_no_std(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t duration_since_epoch); +void ChannelInfo_set_features(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * Returns whether the given quantity is valid for the offer. + * Source node of the first direction of a channel */ -MUST_USE_RES bool Offer_is_valid_quantity(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t quantity); +struct LDKNodeId ChannelInfo_get_node_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * Source node of the first direction of a channel */ -MUST_USE_RES bool Offer_expects_quantity(const struct LDKOffer *NONNULL_PTR this_arg); +void ChannelInfo_set_node_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * Creates an [`InvoiceRequestBuilder`] for the offer, which - * - derives the [`InvoiceRequest::payer_signing_pubkey`] such that a different key can be used - * for each request in order to protect the sender's privacy, - * - sets [`InvoiceRequest::payer_metadata`] when [`InvoiceRequestBuilder::build_and_sign`] is - * called such that it can be used by [`Bolt12Invoice::verify_using_metadata`] to determine - * if the invoice was requested using a base [`ExpandedKey`] from which the payer id was - * derived, and - * - includes the [`PaymentId`] encrypted in [`InvoiceRequest::payer_metadata`] so that it can - * be used when sending the payment for the requested invoice. - * - * Errors if the offer contains unknown required features. - * - * [`InvoiceRequest::payer_signing_pubkey`]: crate::offers::invoice_request::InvoiceRequest::payer_signing_pubkey - * [`InvoiceRequest::payer_metadata`]: crate::offers::invoice_request::InvoiceRequest::payer_metadata - * [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata - * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey + * Source node of the second direction of a channel */ -MUST_USE_RES struct LDKCResult_InvoiceRequestWithDerivedPayerSigningPubkeyBuilderBolt12SemanticErrorZ Offer_request_invoice(const struct LDKOffer *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce, struct LDKThirtyTwoBytes payment_id); +struct LDKNodeId ChannelInfo_get_node_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the Offer. + * Source node of the second direction of a channel */ -uint64_t Offer_hash(const struct LDKOffer *NONNULL_PTR o); +void ChannelInfo_set_node_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * Read a Offer from a byte array, created by Offer_write + * The channel capacity as seen on-chain, if chain lookup is available. */ -struct LDKCResult_OfferDecodeErrorZ Offer_read(struct LDKu8slice ser); +struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Serialize the Offer object into a byte array which can be read by Offer_read + * The channel capacity as seen on-chain, if chain lookup is available. */ -struct LDKCVec_u8Z Offer_write(const struct LDKOffer *NONNULL_PTR obj); +void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Frees any resources used by the Amount + * Details about the first direction of a channel + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void Amount_free(struct LDKAmount this_ptr); +struct LDKChannelUpdateInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Creates a copy of the Amount + * Details about the first direction of a channel + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKAmount Amount_clone(const struct LDKAmount *NONNULL_PTR orig); +void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); /** - * Utility method to constructs a new Bitcoin-variant Amount + * Details about the second direction of a channel + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKAmount Amount_bitcoin(uint64_t amount_msats); +struct LDKChannelUpdateInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Currency-variant Amount + * Details about the second direction of a channel + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKAmount Amount_currency(struct LDKThreeBytes iso4217_code, uint64_t amount); +void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); /** - * Frees any resources used by the Quantity + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void Quantity_free(struct LDKQuantity this_ptr); +struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Creates a copy of the Quantity + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKQuantity Quantity_clone(const struct LDKQuantity *NONNULL_PTR orig); +void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); /** - * Utility method to constructs a new Bounded-variant Quantity + * Creates a copy of the ChannelInfo */ -struct LDKQuantity Quantity_bounded(uint64_t a); +struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); /** - * Utility method to constructs a new Unbounded-variant Quantity + * Checks if two ChannelInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKQuantity Quantity_unbounded(void); +bool ChannelInfo_eq(const struct LDKChannelInfo *NONNULL_PTR a, const struct LDKChannelInfo *NONNULL_PTR b); /** - * Utility method to constructs a new One-variant Quantity + * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKQuantity Quantity_one(void); +MUST_USE_RES struct LDKChannelUpdateInfo ChannelInfo_get_directional_info(const struct LDKChannelInfo *NONNULL_PTR this_arg, uint8_t channel_flags); /** - * Read a Offer object from a string + * Get the string representation of a ChannelInfo object */ -struct LDKCResult_OfferBolt12ParseErrorZ Offer_from_str(struct LDKStr s); +struct LDKStr ChannelInfo_to_str(const struct LDKChannelInfo *NONNULL_PTR o); /** - * Get the string representation of a Offer object + * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read */ -struct LDKStr Offer_to_str(const struct LDKOffer *NONNULL_PTR o); +struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); /** - * Frees any resources used by the InvoiceWithExplicitSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. + * Read a ChannelInfo from a byte array, created by ChannelInfo_write */ -void InvoiceWithExplicitSigningPubkeyBuilder_free(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_obj); +struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); /** - * Frees any resources used by the InvoiceWithDerivedSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. + * Frees any resources used by the DirectedChannelInfo, if is_owned is set and inner is non-NULL. */ -void InvoiceWithDerivedSigningPubkeyBuilder_free(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_obj); +void DirectedChannelInfo_free(struct LDKDirectedChannelInfo this_obj); /** - * Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. + * Creates a copy of the DirectedChannelInfo */ -MUST_USE_RES struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ InvoiceWithExplicitSigningPubkeyBuilder_build(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg); +struct LDKDirectedChannelInfo DirectedChannelInfo_clone(const struct LDKDirectedChannelInfo *NONNULL_PTR orig); /** - *Sets the [`Bolt12Invoice::relative_expiry`] - *as seconds since [`Bolt12Invoice::created_at`]. - *Any expiry that has already passed is valid and can be checked for using - *[`Bolt12Invoice::is_expired`]. - * - * Successive calls to this method will override the previous setting. + * Returns information for the channel. */ -MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, uint32_t relative_expiry_secs); +MUST_USE_RES struct LDKChannelInfo DirectedChannelInfo_channel(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - *Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. + * Returns the [`EffectiveCapacity`] of the channel in the direction. * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. + * This is either the total capacity from the funding transaction, if known, or the + * `htlc_maximum_msat` for the direction as advertised by the gossip network, if known, + * otherwise. */ -MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, const uint8_t (*script_hash)[32]); +MUST_USE_RES struct LDKEffectiveCapacity DirectedChannelInfo_effective_capacity(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - *Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. + * Returns the `node_id` of the source hop. * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. + * Refers to the `node_id` forwarding the payment to the next hop. */ -MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, const uint8_t (*pubkey_hash)[20]); +MUST_USE_RES struct LDKNodeId DirectedChannelInfo_source(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - *Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. + * Returns the `node_id` of the target hop. * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2TR addresses. + * Refers to the `node_id` receiving the payment from the previous hop. */ -MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, struct LDKTweakedPublicKey output_key); +MUST_USE_RES struct LDKNodeId DirectedChannelInfo_target(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - *Sets [`Bolt12Invoice::invoice_features`] - *to indicate MPP may be used. Otherwise, MPP is disallowed. + * Frees any resources used by the EffectiveCapacity */ -MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg); +void EffectiveCapacity_free(struct LDKEffectiveCapacity this_ptr); /** - * Builds a signed [`Bolt12Invoice`] after checking for valid semantics. + * Creates a copy of the EffectiveCapacity */ -MUST_USE_RES struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg); +struct LDKEffectiveCapacity EffectiveCapacity_clone(const struct LDKEffectiveCapacity *NONNULL_PTR orig); /** - *Sets the [`Bolt12Invoice::relative_expiry`] - *as seconds since [`Bolt12Invoice::created_at`]. - *Any expiry that has already passed is valid and can be checked for using - *[`Bolt12Invoice::is_expired`]. - * - * Successive calls to this method will override the previous setting. + * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity */ -MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, uint32_t relative_expiry_secs); +struct LDKEffectiveCapacity EffectiveCapacity_exact_liquidity(uint64_t liquidity_msat); /** - *Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. - * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. + * Utility method to constructs a new AdvertisedMaxHTLC-variant EffectiveCapacity */ -MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, const uint8_t (*script_hash)[32]); +struct LDKEffectiveCapacity EffectiveCapacity_advertised_max_htlc(uint64_t amount_msat); /** - *Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. - * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. + * Utility method to constructs a new Total-variant EffectiveCapacity */ -MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, const uint8_t (*pubkey_hash)[20]); +struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat, uint64_t htlc_maximum_msat); /** - *Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. - * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2TR addresses. + * Utility method to constructs a new Infinite-variant EffectiveCapacity */ -MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, struct LDKTweakedPublicKey output_key); +struct LDKEffectiveCapacity EffectiveCapacity_infinite(void); /** - *Sets [`Bolt12Invoice::invoice_features`] - *to indicate MPP may be used. Otherwise, MPP is disallowed. + * Utility method to constructs a new HintMaxHTLC-variant EffectiveCapacity */ -MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg); +struct LDKEffectiveCapacity EffectiveCapacity_hint_max_htlc(uint64_t amount_msat); /** - * Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Unknown-variant EffectiveCapacity */ -void UnsignedBolt12Invoice_free(struct LDKUnsignedBolt12Invoice this_obj); +struct LDKEffectiveCapacity EffectiveCapacity_unknown(void); /** - * Creates a copy of the UnsignedBolt12Invoice + * Returns the effective capacity denominated in millisatoshi. */ -struct LDKUnsignedBolt12Invoice UnsignedBolt12Invoice_clone(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR orig); +MUST_USE_RES uint64_t EffectiveCapacity_as_msat(const struct LDKEffectiveCapacity *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read */ -void SignBolt12InvoiceFn_free(struct LDKSignBolt12InvoiceFn this_ptr); +struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); /** - * Returns the [`TaggedHash`] of the invoice to sign. + * Read a RoutingFees from a byte array, created by RoutingFees_write */ -MUST_USE_RES struct LDKTaggedHash UnsignedBolt12Invoice_tagged_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); /** - * Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL. + * Frees any resources used by the NodeAnnouncementDetails, if is_owned is set and inner is non-NULL. */ -void Bolt12Invoice_free(struct LDKBolt12Invoice this_obj); +void NodeAnnouncementDetails_free(struct LDKNodeAnnouncementDetails this_obj); /** - * Creates a copy of the Bolt12Invoice + * Protocol features the node announced support for */ -struct LDKBolt12Invoice Bolt12Invoice_clone(const struct LDKBolt12Invoice *NONNULL_PTR orig); +struct LDKNodeFeatures NodeAnnouncementDetails_get_features(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); /** - * Paths to the recipient originating from publicly reachable nodes, including information - * needed for routing payments across them. - * - * Blinded paths provide recipient privacy by obfuscating its node id. Note, however, that this - * privacy is lost if a public node id is used for - *[`UnsignedBolt12Invoice::signing_pubkey`]. + * Protocol features the node announced support for */ -MUST_USE_RES struct LDKCVec_BlindedPaymentPathZ UnsignedBolt12Invoice_payment_paths(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void NodeAnnouncementDetails_set_features(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * Duration since the Unix epoch when the invoice was created. + * When the last known update to the node state was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES uint64_t UnsignedBolt12Invoice_created_at(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +uint32_t NodeAnnouncementDetails_get_last_update(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); /** - * Duration since - *[`UnsignedBolt12Invoice::created_at`] - * when the invoice has expired and therefore should no longer be paid. + * When the last known update to the node state was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES uint64_t UnsignedBolt12Invoice_relative_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void NodeAnnouncementDetails_set_last_update(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, uint32_t val); /** - * Whether the invoice has expired. + * Color assigned to the node */ -MUST_USE_RES bool UnsignedBolt12Invoice_is_expired(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +const uint8_t (*NodeAnnouncementDetails_get_rgb(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr))[3]; /** - * Fallback addresses for paying the invoice on-chain, in order of most-preferred to - * least-preferred. + * Color assigned to the node */ -MUST_USE_RES struct LDKCVec_StrZ UnsignedBolt12Invoice_fallbacks(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void NodeAnnouncementDetails_set_rgb(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKThreeBytes val); /** - * Features pertaining to paying an invoice. + * Moniker assigned to the node. + * May be invalid or malicious (eg control chars), + * should not be exposed to the user. */ -MUST_USE_RES struct LDKBolt12InvoiceFeatures UnsignedBolt12Invoice_invoice_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKNodeAlias NodeAnnouncementDetails_get_alias(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); /** - * A typically transient public key corresponding to the key used to sign the invoice. - * - * If the invoices was created in response to an [`Offer`], then this will be: - * - [`Offer::issuer_signing_pubkey`] if it's `Some`, otherwise - * - the final blinded node id from a [`BlindedMessagePath`] in [`Offer::paths`] if `None`. - * - * If the invoice was created in response to a [`Refund`], then it is a valid pubkey chosen by - * the recipient. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::issuer_signing_pubkey`]: crate::offers::offer::Offer::issuer_signing_pubkey - * [`Offer::paths`]: crate::offers::offer::Offer::paths - * [`Refund`]: crate::offers::refund::Refund + * Moniker assigned to the node. + * May be invalid or malicious (eg control chars), + * should not be exposed to the user. */ -MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_signing_pubkey(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void NodeAnnouncementDetails_set_alias(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKNodeAlias val); /** - * The chains that may be used when paying a requested invoice. - * - * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. + * Internet-level addresses via which one can connect to the node * - * [`Offer::chains`]: crate::offers::offer::Offer::chains + * Returns a copy of the field. */ -MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ UnsignedBolt12Invoice_offer_chains(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCVec_SocketAddressZ NodeAnnouncementDetails_get_addresses(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); /** - * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the - * invoice originated from an offer. - * - * From [`InvoiceRequest::chain`] or [`Refund::chain`]. - * - * [`offer_chains`]: Self::offer_chains - * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain + * Internet-level addresses via which one can connect to the node */ -MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_chain(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void NodeAnnouncementDetails_set_addresses(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKCVec_SocketAddressZ val); /** - * Opaque bytes set by the originating [`Offer`]. - * - * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or - * if the [`Offer`] did not set it. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::metadata`]: crate::offers::offer::Offer::metadata + * Constructs a new NodeAnnouncementDetails given each field */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedBolt12Invoice_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeAnnouncementDetails NodeAnnouncementDetails_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKNodeAlias alias_arg, struct LDKCVec_SocketAddressZ addresses_arg); /** - * The minimum amount required for a successful payment of a single item. - * - * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if - * the [`Offer`] did not set it. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::amount`]: crate::offers::offer::Offer::amount + * Creates a copy of the NodeAnnouncementDetails */ -MUST_USE_RES struct LDKCOption_AmountZ UnsignedBolt12Invoice_amount(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKNodeAnnouncementDetails NodeAnnouncementDetails_clone(const struct LDKNodeAnnouncementDetails *NONNULL_PTR orig); /** - * Features pertaining to the originating [`Offer`]. - * - * From [`Offer::offer_features`]; `None` if the invoice was created in response to a - * [`Refund`]. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two NodeAnnouncementDetailss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKOfferFeatures UnsignedBolt12Invoice_offer_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +bool NodeAnnouncementDetails_eq(const struct LDKNodeAnnouncementDetails *NONNULL_PTR a, const struct LDKNodeAnnouncementDetails *NONNULL_PTR b); /** - * A complete description of the purpose of the originating offer or refund. - * - * From [`Offer::description`] or [`Refund::description`]. - * - * [`Offer::description`]: crate::offers::offer::Offer::description - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the NodeAnnouncementInfo */ -MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_description(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_ptr); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. - * - * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry + * Creates a copy of the NodeAnnouncementInfo */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_absolute_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); /** - * The issuer of the offer or refund. - * - * From [`Offer::issuer`] or [`Refund::issuer`]. - * - * [`Offer::issuer`]: crate::offers::offer::Offer::issuer - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new Relayed-variant NodeAnnouncementInfo */ -MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_issuer(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_relayed(struct LDKNodeAnnouncement a); /** - * Paths to the recipient originating from publicly reachable nodes. - * - * From [`Offer::paths`] or [`Refund::paths`]. - * - * [`Offer::paths`]: crate::offers::offer::Offer::paths + * Utility method to constructs a new Local-variant NodeAnnouncementInfo */ -MUST_USE_RES struct LDKCVec_BlindedMessagePathZ UnsignedBolt12Invoice_message_paths(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_local(struct LDKNodeAnnouncementDetails a); /** - * The quantity of items supported. - * - * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a - * [`Refund`]. - * - * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity + * Checks if two NodeAnnouncementInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKCOption_QuantityZ UnsignedBolt12Invoice_supported_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +bool NodeAnnouncementInfo_eq(const struct LDKNodeAnnouncementInfo *NONNULL_PTR a, const struct LDKNodeAnnouncementInfo *NONNULL_PTR b); /** - * The public key used by the recipient to sign invoices. - * - * From [`Offer::issuer_signing_pubkey`] and may be `None`; also `None` if the invoice was - * created in response to a [`Refund`]. - * - * [`Offer::issuer_signing_pubkey`]: crate::offers::offer::Offer::issuer_signing_pubkey - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Protocol features the node announced support for */ -MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_issuer_signing_pubkey(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeFeatures NodeAnnouncementInfo_features(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * An unpredictable series of bytes from the payer. + * When the last known update to the node state was issued. * - * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. + * Value may or may not be a timestamp, depending on the policy of the origin node. */ -MUST_USE_RES struct LDKu8slice UnsignedBolt12Invoice_payer_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES uint32_t NodeAnnouncementInfo_last_update(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Features pertaining to requesting an invoice. - * - * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. + * Color assigned to the node */ -MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedBolt12Invoice_invoice_request_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThreeBytes NodeAnnouncementInfo_rgb(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * The quantity of items requested or refunded for. + * Moniker assigned to the node. * - * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. + * May be invalid or malicious (eg control chars), should not be exposed to the user. */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeAlias NodeAnnouncementInfo_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * A possibly transient pubkey used to sign the invoice request or to send an invoice for a - * refund in case there are no [`message_paths`]. - * - * [`message_paths`]: Self::message_paths + * Internet-level addresses via which one can connect to the node */ -MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_payer_signing_pubkey(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_SocketAddressZ NodeAnnouncementInfo_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * A payer-provided note reflected back in the invoice. + * An initial announcement of the node * - * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. + * Not stored if contains excess data to prevent DoS. * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_payer_note(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncementInfo_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * SHA256 hash of the payment preimage that will be given in return for paying the invoice. + * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read */ -MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_payment_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *NONNULL_PTR obj); /** - * The minimum amount required for a successful payment of the invoice. + * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write */ -MUST_USE_RES uint64_t UnsignedBolt12Invoice_amount_msats(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); /** - * Paths to the recipient originating from publicly reachable nodes, including information - * needed for routing payments across them. - * - * Blinded paths provide recipient privacy by obfuscating its node id. Note, however, that this - * privacy is lost if a public node id is used for - *[`Bolt12Invoice::signing_pubkey`]. + * Frees any resources used by the NodeAlias, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCVec_BlindedPaymentPathZ Bolt12Invoice_payment_paths(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void NodeAlias_free(struct LDKNodeAlias this_obj); + +const uint8_t (*NodeAlias_get_a(const struct LDKNodeAlias *NONNULL_PTR this_ptr))[32]; + +void NodeAlias_set_a(struct LDKNodeAlias *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Duration since the Unix epoch when the invoice was created. + * Constructs a new NodeAlias given each field */ -MUST_USE_RES uint64_t Bolt12Invoice_created_at(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeAlias NodeAlias_new(struct LDKThirtyTwoBytes a_arg); /** - * Duration since - *[`Bolt12Invoice::created_at`] - * when the invoice has expired and therefore should no longer be paid. + * Creates a copy of the NodeAlias */ -MUST_USE_RES uint64_t Bolt12Invoice_relative_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKNodeAlias NodeAlias_clone(const struct LDKNodeAlias *NONNULL_PTR orig); /** - * Whether the invoice has expired. + * Generates a non-cryptographic 64-bit hash of the NodeAlias. */ -MUST_USE_RES bool Bolt12Invoice_is_expired(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +uint64_t NodeAlias_hash(const struct LDKNodeAlias *NONNULL_PTR o); /** - * Fallback addresses for paying the invoice on-chain, in order of most-preferred to - * least-preferred. + * Checks if two NodeAliass contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCVec_StrZ Bolt12Invoice_fallbacks(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +bool NodeAlias_eq(const struct LDKNodeAlias *NONNULL_PTR a, const struct LDKNodeAlias *NONNULL_PTR b); /** - * Features pertaining to paying an invoice. + * Get the string representation of a NodeAlias object */ -MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12Invoice_invoice_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKStr NodeAlias_to_str(const struct LDKNodeAlias *NONNULL_PTR o); /** - * A typically transient public key corresponding to the key used to sign the invoice. - * - * If the invoices was created in response to an [`Offer`], then this will be: - * - [`Offer::issuer_signing_pubkey`] if it's `Some`, otherwise - * - the final blinded node id from a [`BlindedMessagePath`] in [`Offer::paths`] if `None`. - * - * If the invoice was created in response to a [`Refund`], then it is a valid pubkey chosen by - * the recipient. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::issuer_signing_pubkey`]: crate::offers::offer::Offer::issuer_signing_pubkey - * [`Offer::paths`]: crate::offers::offer::Offer::paths - * [`Refund`]: crate::offers::refund::Refund + * Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read */ -MUST_USE_RES struct LDKPublicKey Bolt12Invoice_signing_pubkey(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCVec_u8Z NodeAlias_write(const struct LDKNodeAlias *NONNULL_PTR obj); /** - * The chains that may be used when paying a requested invoice. - * - * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. - * - * [`Offer::chains`]: crate::offers::offer::Offer::chains + * Read a NodeAlias from a byte array, created by NodeAlias_write */ -MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ Bolt12Invoice_offer_chains(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCResult_NodeAliasDecodeErrorZ NodeAlias_read(struct LDKu8slice ser); /** - * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the - * invoice originated from an offer. - * - * From [`InvoiceRequest::chain`] or [`Refund::chain`]. - * - * [`offer_chains`]: Self::offer_chains - * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain + * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_chain(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void NodeInfo_free(struct LDKNodeInfo this_obj); /** - * Opaque bytes set by the originating [`Offer`]. - * - * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or - * if the [`Offer`] did not set it. + * All valid channels a node has announced * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::metadata`]: crate::offers::offer::Offer::metadata + * Returns a copy of the field. */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ Bolt12Invoice_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCVec_u64Z NodeInfo_get_channels(const struct LDKNodeInfo *NONNULL_PTR this_ptr); /** - * The minimum amount required for a successful payment of a single item. - * - * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if - * the [`Offer`] did not set it. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::amount`]: crate::offers::offer::Offer::amount + * All valid channels a node has announced */ -MUST_USE_RES struct LDKCOption_AmountZ Bolt12Invoice_amount(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void NodeInfo_set_channels(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Features pertaining to the originating [`Offer`]. - * - * From [`Offer::offer_features`]; `None` if the invoice was created in response to a - * [`Refund`]. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features + * More information about a node from node_announcement. + * Optional because we store a Node entry after learning about it from + * a channel announcement, but before receiving a node announcement. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Returns a copy of the field. */ -MUST_USE_RES struct LDKOfferFeatures Bolt12Invoice_offer_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCOption_NodeAnnouncementInfoZ NodeInfo_get_announcement_info(const struct LDKNodeInfo *NONNULL_PTR this_ptr); /** - * A complete description of the purpose of the originating offer or refund. - * - * From [`Offer::description`] or [`Refund::description`]. - * - * [`Offer::description`]: crate::offers::offer::Offer::description - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * More information about a node from node_announcement. + * Optional because we store a Node entry after learning about it from + * a channel announcement, but before receiving a node announcement. */ -MUST_USE_RES struct LDKPrintableString Bolt12Invoice_description(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCOption_NodeAnnouncementInfoZ val); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. - * - * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry + * Creates a copy of the NodeInfo */ -MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_absolute_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); /** - * The issuer of the offer or refund. - * - * From [`Offer::issuer`] or [`Refund::issuer`]. - * - * [`Offer::issuer`]: crate::offers::offer::Offer::issuer - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two NodeInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKPrintableString Bolt12Invoice_issuer(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +bool NodeInfo_eq(const struct LDKNodeInfo *NONNULL_PTR a, const struct LDKNodeInfo *NONNULL_PTR b); /** - * Paths to the recipient originating from publicly reachable nodes. - * - * From [`Offer::paths`] or [`Refund::paths`]. - * - * [`Offer::paths`]: crate::offers::offer::Offer::paths + * Returns whether the node has only announced Tor addresses. */ -MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Bolt12Invoice_message_paths(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeInfo_is_tor_only(const struct LDKNodeInfo *NONNULL_PTR this_arg); /** - * The quantity of items supported. - * - * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a - * [`Refund`]. - * - * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity + * Get the string representation of a NodeInfo object */ -MUST_USE_RES struct LDKCOption_QuantityZ Bolt12Invoice_supported_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKStr NodeInfo_to_str(const struct LDKNodeInfo *NONNULL_PTR o); /** - * The public key used by the recipient to sign invoices. - * - * From [`Offer::issuer_signing_pubkey`] and may be `None`; also `None` if the invoice was - * created in response to a [`Refund`]. - * - * [`Offer::issuer_signing_pubkey`]: crate::offers::offer::Offer::issuer_signing_pubkey - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read */ -MUST_USE_RES struct LDKPublicKey Bolt12Invoice_issuer_signing_pubkey(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *NONNULL_PTR obj); /** - * An unpredictable series of bytes from the payer. - * - * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. + * Read a NodeInfo from a byte array, created by NodeInfo_write */ -MUST_USE_RES struct LDKu8slice Bolt12Invoice_payer_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser); /** - * Features pertaining to requesting an invoice. - * - * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. + * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read */ -MUST_USE_RES struct LDKInvoiceRequestFeatures Bolt12Invoice_invoice_request_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR obj); /** - * The quantity of items requested or refunded for. - * - * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. + * Read a NetworkGraph from a byte array, created by NetworkGraph_write */ -MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser, struct LDKLogger arg); /** - * A possibly transient pubkey used to sign the invoice request or to send an invoice for a - * refund in case there are no [`message_paths`]. - * - * [`message_paths`]: Self::message_paths + * Get the string representation of a NetworkGraph object */ -MUST_USE_RES struct LDKPublicKey Bolt12Invoice_payer_signing_pubkey(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKStr NetworkGraph_to_str(const struct LDKNetworkGraph *NONNULL_PTR o); /** - * A payer-provided note reflected back in the invoice. - * - * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a new, empty, network graph. */ -MUST_USE_RES struct LDKPrintableString Bolt12Invoice_payer_note(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(enum LDKNetwork network, struct LDKLogger logger); /** - * SHA256 hash of the payment preimage that will be given in return for paying the invoice. + * Returns a read-only view of the network graph. */ -MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_payment_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * The minimum amount required for a successful payment of the invoice. + * The unix timestamp provided by the most recent rapid gossip sync. + * It will be set by the rapid sync process after every sync completion. */ -MUST_USE_RES uint64_t Bolt12Invoice_amount_msats(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u32Z NetworkGraph_get_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`]. + * Update the unix timestamp provided by the most recent rapid gossip sync. + * This should be done automatically by the rapid sync process after every sync completion. */ -MUST_USE_RES struct LDKSchnorrSignature Bolt12Invoice_signature(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void NetworkGraph_set_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint32_t last_rapid_gossip_sync_timestamp); /** - * Hash that was used for signing the invoice. + * For an already known node (from channel announcements), update its stored properties from a + * given node announcement. + * + * You probably don't want to call this directly, instead relying on a P2PGossipSync's + * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. */ -MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_signable_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); /** - * Verifies that the invoice was for a request or refund created using the given key by - * checking the payer metadata from the invoice request. + * For an already known node (from channel announcements), update its stored properties from a + * given node announcement without verifying the associated signatures. Because we aren't + * given the associated signatures here we cannot relay the node announcement to any of our + * peers. + */ +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); + +/** + * Store or update channel info from a channel announcement. * - * Returns the associated [`PaymentId`] to use when sending the payment. + * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s + * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. + * + * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify + * the corresponding UTXO exists on chain and is correctly-formatted. */ -MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ Bolt12Invoice_verify_using_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR key); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); /** - * Verifies that the invoice was for a request or refund created using the given key by - * checking a payment id and nonce included with the [`BlindedMessagePath`] for which the invoice was - * sent through. + * Store or update channel info from a channel announcement. + * + * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s + * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. + * + * This will skip verification of if the channel is actually on-chain. */ -MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ Bolt12Invoice_verify_using_payer_data(const struct LDKBolt12Invoice *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id, struct LDKNonce nonce, const struct LDKExpandedKey *NONNULL_PTR key); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement_no_lookup(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg); /** - * Generates a non-cryptographic 64-bit hash of the Bolt12Invoice. + * Store or update channel info from a channel announcement without verifying the associated + * signatures. Because we aren't given the associated signatures here we cannot relay the + * channel announcement to any of our peers. + * + * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify + * the corresponding UTXO exists on chain and is correctly-formatted. */ -uint64_t Bolt12Invoice_hash(const struct LDKBolt12Invoice *NONNULL_PTR o); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); /** - * Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read + * Update channel from partial announcement data received via rapid gossip sync + * + * `timestamp: u64`: Timestamp emulating the backdated original announcement receipt (by the + * rapid gossip sync server) + * + * All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields. */ -struct LDKCVec_u8Z UnsignedBolt12Invoice_write(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_add_channel_from_partial_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, uint64_t timestamp, struct LDKChannelFeatures features, struct LDKPublicKey node_id_1, struct LDKPublicKey node_id_2); /** - * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read + * Marks a channel in the graph as failed permanently. + * + * The channel and any node for which this was their last channel are removed from the graph. */ -struct LDKCVec_u8Z Bolt12Invoice_write(const struct LDKBolt12Invoice *NONNULL_PTR obj); +void NetworkGraph_channel_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); /** - * Read a Bolt12Invoice from a byte array, created by Bolt12Invoice_write + * Marks a node in the graph as permanently failed, effectively removing it and its channels + * from local storage. */ -struct LDKCResult_Bolt12InvoiceDecodeErrorZ Bolt12Invoice_read(struct LDKu8slice ser); +void NetworkGraph_node_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey node_id); /** - * Frees any resources used by the InvoiceError, if is_owned is set and inner is non-NULL. + * Removes information about channels that we haven't heard any updates about in some time. + * This can be used regularly to prune the network graph of channels that likely no longer + * exist. + * + * While there is no formal requirement that nodes regularly re-broadcast their channel + * updates every two weeks, the non-normative section of BOLT 7 currently suggests that + * pruning occur for updates which are at least two weeks old, which we implement here. + * + * Note that for users of the `lightning-background-processor` crate this method may be + * automatically called regularly for you. + * + * This method will also cause us to stop tracking removed nodes and channels if they have been + * in the map for a while so that these can be resynced from gossip in the future. + * + * This method is only available with the `std` feature. See + * [`NetworkGraph::remove_stale_channels_and_tracking_with_time`] for non-`std` use. */ -void InvoiceError_free(struct LDKInvoiceError this_obj); +void NetworkGraph_remove_stale_channels_and_tracking(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. + * Removes information about channels that we haven't heard any updates about in some time. + * This can be used regularly to prune the network graph of channels that likely no longer + * exist. * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * While there is no formal requirement that nodes regularly re-broadcast their channel + * updates every two weeks, the non-normative section of BOLT 7 currently suggests that + * pruning occur for updates which are at least two weeks old, which we implement here. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * This method will also cause us to stop tracking removed nodes and channels if they have been + * in the map for a while so that these can be resynced from gossip in the future. + * + *This function takes the current unix time as an argument. For users with the `std` feature + *enabled, [`NetworkGraph::remove_stale_channels_and_tracking`] may be preferable. */ -struct LDKErroneousField InvoiceError_get_erroneous_field(const struct LDKInvoiceError *NONNULL_PTR this_ptr); +void NetworkGraph_remove_stale_channels_and_tracking_with_time(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t current_time_unix); /** - * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. + * For an already known (from announcement) channel, update info about one of the directions + * of the channel. * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s + * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * If not built with `std`, any updates with a timestamp more than two weeks in the past or + * materially in the future will be rejected. */ -void InvoiceError_set_erroneous_field(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKErroneousField val); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); /** - * An explanation of the error. + * For an already known (from announcement) channel, update info about one of the directions + * of the channel without verifying the associated signatures. Because we aren't given the + * associated signatures here we cannot relay the channel update to any of our peers. + * + * If not built with `std`, any updates with a timestamp more than two weeks in the past or + * materially in the future will be rejected. */ -struct LDKUntrustedString InvoiceError_get_message(const struct LDKInvoiceError *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); /** - * An explanation of the error. + * For an already known (from announcement) channel, verify the given [`ChannelUpdate`]. + * + * This checks whether the update currently is applicable by [`Self::update_channel`]. + * + * If not built with `std`, any updates with a timestamp more than two weeks in the past or + * materially in the future will be rejected. */ -void InvoiceError_set_message(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKUntrustedString val); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_verify_channel_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); /** - * Constructs a new InvoiceError given each field + * Returns information on a channel with the given id. * - * Note that erroneous_field_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKInvoiceError InvoiceError_new(struct LDKErroneousField erroneous_field_arg, struct LDKUntrustedString message_arg); +MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); /** - * Creates a copy of the InvoiceError + * Returns the list of channels in the graph */ -struct LDKInvoiceError InvoiceError_clone(const struct LDKInvoiceError *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_u64Z ReadOnlyNetworkGraph_list_channels(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); /** - * Frees any resources used by the ErroneousField, if is_owned is set and inner is non-NULL. + * Returns information on a node with the given id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ErroneousField_free(struct LDKErroneousField this_obj); +MUST_USE_RES struct LDKNodeInfo ReadOnlyNetworkGraph_node(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * The type number of the TLV field containing the error. + * Returns the list of nodes in the graph */ -uint64_t ErroneousField_get_tlv_fieldnum(const struct LDKErroneousField *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_NodeIdZ ReadOnlyNetworkGraph_list_nodes(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); /** - * The type number of the TLV field containing the error. + * Get network addresses by node id. + * Returns None if the requested node is completely unknown, + * or if node announcement for the node was never received. */ -void ErroneousField_set_tlv_fieldnum(struct LDKErroneousField *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCOption_CVec_SocketAddressZZ ReadOnlyNetworkGraph_get_addresses(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey pubkey); /** - * A value to use for the TLV field to avoid the error. - * - * Returns a copy of the field. + * Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL. */ -struct LDKCOption_CVec_u8ZZ ErroneousField_get_suggested_value(const struct LDKErroneousField *NONNULL_PTR this_ptr); +void DefaultRouter_free(struct LDKDefaultRouter this_obj); /** - * A value to use for the TLV field to avoid the error. + * Creates a new router. */ -void ErroneousField_set_suggested_value(struct LDKErroneousField *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKEntropySource entropy_source, struct LDKLockableScore scorer, struct LDKProbabilisticScoringFeeParameters score_params); /** - * Constructs a new ErroneousField given each field + * Constructs a new Router which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Router must be freed before this_arg is */ -MUST_USE_RES struct LDKErroneousField ErroneousField_new(uint64_t tlv_fieldnum_arg, struct LDKCOption_CVec_u8ZZ suggested_value_arg); +struct LDKRouter DefaultRouter_as_Router(const struct LDKDefaultRouter *NONNULL_PTR this_arg); /** - * Creates a copy of the ErroneousField + * Calls the free function if one is set */ -struct LDKErroneousField ErroneousField_clone(const struct LDKErroneousField *NONNULL_PTR orig); +void Router_free(struct LDKRouter this_ptr); /** - * Creates an [`InvoiceError`] with the given message. + * Frees any resources used by the ScorerAccountingForInFlightHtlcs, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKInvoiceError InvoiceError_from_string(struct LDKStr s); +void ScorerAccountingForInFlightHtlcs_free(struct LDKScorerAccountingForInFlightHtlcs this_obj); /** - * Get the string representation of a InvoiceError object + * Initialize a new `ScorerAccountingForInFlightHtlcs`. */ -struct LDKStr InvoiceError_to_str(const struct LDKInvoiceError *NONNULL_PTR o); +MUST_USE_RES struct LDKScorerAccountingForInFlightHtlcs ScorerAccountingForInFlightHtlcs_new(struct LDKScoreLookUp scorer, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs); /** - * Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is */ -struct LDKCVec_u8Z InvoiceError_write(const struct LDKInvoiceError *NONNULL_PTR obj); +struct LDKScoreLookUp ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(const struct LDKScorerAccountingForInFlightHtlcs *NONNULL_PTR this_arg); /** - * Read a InvoiceError from a byte array, created by InvoiceError_write + * Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_InvoiceErrorDecodeErrorZ InvoiceError_read(struct LDKu8slice ser); +void InFlightHtlcs_free(struct LDKInFlightHtlcs this_obj); /** - * Frees any resources used by the InvoiceRequestWithDerivedPayerSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. + * Creates a copy of the InFlightHtlcs */ -void InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_free(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_obj); +struct LDKInFlightHtlcs InFlightHtlcs_clone(const struct LDKInFlightHtlcs *NONNULL_PTR orig); /** - * Builds a signed [`InvoiceRequest`] after checking for valid semantics. + * Constructs an empty `InFlightHtlcs`. */ -MUST_USE_RES struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_build_and_sign(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg); +MUST_USE_RES struct LDKInFlightHtlcs InFlightHtlcs_new(void); + +/** + * Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`. + */ +void InFlightHtlcs_process_path(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKPath *NONNULL_PTR path, struct LDKPublicKey payer_node_id); /** - * Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not - * called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported - * by the offer. - * - * Successive calls to this method will override the previous setting. + * Adds a known HTLC given the public key of the HTLC source, target, and short channel + * id. */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_chain(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg, enum LDKNetwork network); +void InFlightHtlcs_add_inflight_htlc(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid, uint64_t used_msat); /** - * Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is - * not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]). - * - * Successive calls to this method will override the previous setting. - * - * [`quantity`]: Self::quantity + * Returns liquidity in msat given the public key of the HTLC source, target, and short channel + * id. */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_amount_msats(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg, uint64_t amount_msats); +MUST_USE_RES struct LDKCOption_u64Z InFlightHtlcs_used_liquidity_msat(const struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid); /** - * Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity` - * does not conform to [`Offer::is_valid_quantity`]. - * - * Successive calls to this method will override the previous setting. + * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_quantity(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg, uint64_t quantity); +struct LDKCVec_u8Z InFlightHtlcs_write(const struct LDKInFlightHtlcs *NONNULL_PTR obj); /** - * Sets the [`InvoiceRequest::payer_note`]. - * - * Successive calls to this method will override the previous setting. + * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write */ -MUST_USE_RES void InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_payer_note(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg, struct LDKStr payer_note); +struct LDKCResult_InFlightHtlcsDecodeErrorZ InFlightHtlcs_read(struct LDKu8slice ser); /** - * Sets the [`InvoiceRequest::offer_from_hrn`]. - * - * Successive calls to this method will override the previous setting. + * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES void InvoiceRequestWithDerivedPayerSigningPubkeyBuilder_sourced_from_human_readable_name(struct LDKInvoiceRequestWithDerivedPayerSigningPubkeyBuilder this_arg, struct LDKHumanReadableName hrn); +void RouteHop_free(struct LDKRouteHop this_obj); /** - * Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL. + * The node_id of the node at this hop. */ -void UnsignedInvoiceRequest_free(struct LDKUnsignedInvoiceRequest this_obj); +struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Creates a copy of the UnsignedInvoiceRequest + * The node_id of the node at this hop. */ -struct LDKUnsignedInvoiceRequest UnsignedInvoiceRequest_clone(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR orig); +void RouteHop_set_pubkey(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Calls the free function if one is set + * The node_announcement features of the node at this hop. For the last hop, these may be + * amended to match the features present in the invoice this node generated. */ -void SignInvoiceRequestFn_free(struct LDKSignInvoiceRequestFn this_ptr); +struct LDKNodeFeatures RouteHop_get_node_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Returns the [`TaggedHash`] of the invoice to sign. + * The node_announcement features of the node at this hop. For the last hop, these may be + * amended to match the features present in the invoice this node generated. */ -MUST_USE_RES struct LDKTaggedHash UnsignedInvoiceRequest_tagged_hash(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void RouteHop_set_node_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL. + * The channel that should be used from the previous hop to reach this node. */ -void InvoiceRequest_free(struct LDKInvoiceRequest this_obj); +uint64_t RouteHop_get_short_channel_id(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Creates a copy of the InvoiceRequest + * The channel that should be used from the previous hop to reach this node. */ -struct LDKInvoiceRequest InvoiceRequest_clone(const struct LDKInvoiceRequest *NONNULL_PTR orig); +void RouteHop_set_short_channel_id(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL. + * The channel_announcement features of the channel that should be used from the previous hop + * to reach this node. */ -void VerifiedInvoiceRequest_free(struct LDKVerifiedInvoiceRequest this_obj); +struct LDKChannelFeatures RouteHop_get_channel_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. + * The channel_announcement features of the channel that should be used from the previous hop + * to reach this node. */ -struct LDKOfferId VerifiedInvoiceRequest_get_offer_id(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr); +void RouteHop_set_channel_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. + * The fee taken on this hop (for paying for the use of the *next* channel in the path). + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPaymentPath`], this is the fee paid for use of the entire + * blinded path + * * otherwise, this is the full value of this [`Path`]'s part of the payment */ -void VerifiedInvoiceRequest_set_offer_id(struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr, struct LDKOfferId val); +uint64_t RouteHop_get_fee_msat(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Creates a copy of the VerifiedInvoiceRequest + * The fee taken on this hop (for paying for the use of the *next* channel in the path). + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPaymentPath`], this is the fee paid for use of the entire + * blinded path + * * otherwise, this is the full value of this [`Path`]'s part of the payment */ -struct LDKVerifiedInvoiceRequest VerifiedInvoiceRequest_clone(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR orig); +void RouteHop_set_fee_msat(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); /** - * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). - * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) - * for the selected chain. + * The CLTV delta added for this hop. + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded + * path + * * otherwise, this is the CLTV delta expected at the destination */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ UnsignedInvoiceRequest_chains(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Opaque bytes set by the originator. Useful for authentication and validating fields since it - * is reflected in `invoice_request` messages along with all the other fields from the `offer`. + * The CLTV delta added for this hop. + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded + * path + * * otherwise, this is the CLTV delta expected at the destination */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedInvoiceRequest_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); /** - * The minimum amount required for a successful payment of a single item. + * Indicates whether this hop is possibly announced in the public network graph. + * + * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we + * either know for sure it's announced in the public graph, or if any public channels exist + * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe + * the channel to be unannounced. + * + * Will be `true` for objects serialized with LDK version 0.0.116 and before. */ -MUST_USE_RES struct LDKCOption_AmountZ UnsignedInvoiceRequest_amount(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +bool RouteHop_get_maybe_announced_channel(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * A complete description of the purpose of the payment. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. + * Indicates whether this hop is possibly announced in the public network graph. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we + * either know for sure it's announced in the public graph, or if any public channels exist + * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe + * the channel to be unannounced. + * + * Will be `true` for objects serialized with LDK version 0.0.116 and before. */ -MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_description(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void RouteHop_set_maybe_announced_channel(struct LDKRouteHop *NONNULL_PTR this_ptr, bool val); /** - * Features pertaining to the offer. + * Constructs a new RouteHop given each field */ -MUST_USE_RES struct LDKOfferFeatures UnsignedInvoiceRequest_offer_features(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg, bool maybe_announced_channel_arg); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * If `None`, the offer does not expire. + * Creates a copy of the RouteHop */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_absolute_expiry(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); /** - * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Generates a non-cryptographic 64-bit hash of the RouteHop. */ -MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_issuer(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * Checks if two RouteHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCVec_BlindedMessagePathZ UnsignedInvoiceRequest_paths(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +bool RouteHop_eq(const struct LDKRouteHop *NONNULL_PTR a, const struct LDKRouteHop *NONNULL_PTR b); /** - * The quantity of items supported. + * Serialize the RouteHop object into a byte array which can be read by RouteHop_read */ -MUST_USE_RES struct LDKQuantity UnsignedInvoiceRequest_supported_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCVec_u8Z RouteHop_write(const struct LDKRouteHop *NONNULL_PTR obj); /** - * The public key corresponding to the key used by the recipient to sign invoices. - * - If [`Offer::paths`] is empty, MUST be `Some` and contain the recipient's node id for - * sending an [`InvoiceRequest`]. - * - If [`Offer::paths`] is not empty, MAY be `Some` and contain a transient id. - * - If `None`, the signing pubkey will be the final blinded node id from the - * [`BlindedMessagePath`] in [`Offer::paths`] used to send the [`InvoiceRequest`]. - * - * See also [`Bolt12Invoice::signing_pubkey`]. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice::signing_pubkey`]: crate::offers::invoice::Bolt12Invoice::signing_pubkey - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Read a RouteHop from a byte array, created by RouteHop_write */ -MUST_USE_RES struct LDKPublicKey UnsignedInvoiceRequest_issuer_signing_pubkey(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCResult_RouteHopDecodeErrorZ RouteHop_read(struct LDKu8slice ser); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_signing_pubkey`]. - * - * [`payer_signing_pubkey`]: Self::payer_signing_pubkey + * Frees any resources used by the BlindedTail, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKu8slice UnsignedInvoiceRequest_payer_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void BlindedTail_free(struct LDKBlindedTail this_obj); /** - * A chain from [`Offer::chains`] that the offer is valid for. + * The hops of the [`BlindedPaymentPath`] provided by the recipient. */ -MUST_USE_RES struct LDKThirtyTwoBytes UnsignedInvoiceRequest_chain(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCVec_BlindedHopZ BlindedTail_get_hops(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which - * must be greater than or equal to [`Offer::amount`], converted if necessary. - * - * [`chain`]: Self::chain + * The hops of the [`BlindedPaymentPath`] provided by the recipient. */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_amount_msats(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void BlindedTail_set_hops(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKCVec_BlindedHopZ val); /** - * Returns whether an amount was set in the request; otherwise, if [`amount_msats`] is `Some` - * then it was inferred from the [`Offer::amount`] and [`quantity`]. - * - * [`amount_msats`]: Self::amount_msats - * [`quantity`]: Self::quantity + * The blinding point of the [`BlindedPaymentPath`] provided by the recipient. */ -MUST_USE_RES bool UnsignedInvoiceRequest_has_amount_msats(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKPublicKey BlindedTail_get_blinding_point(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * Features pertaining to requesting an invoice. + * The blinding point of the [`BlindedPaymentPath`] provided by the recipient. */ -MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedInvoiceRequest_invoice_request_features(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void BlindedTail_set_blinding_point(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from + * inferring the destination. May be 0. */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +uint32_t BlindedTail_get_excess_final_cltv_expiry_delta(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * A possibly transient pubkey used to sign the invoice request. + * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from + * inferring the destination. May be 0. */ -MUST_USE_RES struct LDKPublicKey UnsignedInvoiceRequest_payer_signing_pubkey(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void BlindedTail_set_excess_final_cltv_expiry_delta(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint32_t val); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The total amount paid on this [`Path`], excluding the fees. */ -MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_payer_note(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +uint64_t BlindedTail_get_final_value_msat(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * If the [`Offer`] was sourced from a BIP 353 Human Readable Name, this should be set by the - * builder to indicate the original [`HumanReadableName`] which was resolved. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The total amount paid on this [`Path`], excluding the fees. */ -MUST_USE_RES struct LDKHumanReadableName UnsignedInvoiceRequest_offer_from_hrn(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void BlindedTail_set_final_value_msat(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint64_t val); /** - * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). - * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) - * for the selected chain. + * Constructs a new BlindedTail given each field */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ InvoiceRequest_chains(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBlindedTail BlindedTail_new(struct LDKCVec_BlindedHopZ hops_arg, struct LDKPublicKey blinding_point_arg, uint32_t excess_final_cltv_expiry_delta_arg, uint64_t final_value_msat_arg); /** - * Opaque bytes set by the originator. Useful for authentication and validating fields since it - * is reflected in `invoice_request` messages along with all the other fields from the `offer`. + * Creates a copy of the BlindedTail */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ InvoiceRequest_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKBlindedTail BlindedTail_clone(const struct LDKBlindedTail *NONNULL_PTR orig); /** - * The minimum amount required for a successful payment of a single item. + * Generates a non-cryptographic 64-bit hash of the BlindedTail. */ -MUST_USE_RES struct LDKCOption_AmountZ InvoiceRequest_amount(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +uint64_t BlindedTail_hash(const struct LDKBlindedTail *NONNULL_PTR o); /** - * A complete description of the purpose of the payment. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two BlindedTails contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKPrintableString InvoiceRequest_description(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +bool BlindedTail_eq(const struct LDKBlindedTail *NONNULL_PTR a, const struct LDKBlindedTail *NONNULL_PTR b); /** - * Features pertaining to the offer. + * Serialize the BlindedTail object into a byte array which can be read by BlindedTail_read */ -MUST_USE_RES struct LDKOfferFeatures InvoiceRequest_offer_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCVec_u8Z BlindedTail_write(const struct LDKBlindedTail *NONNULL_PTR obj); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * If `None`, the offer does not expire. + * Read a BlindedTail from a byte array, created by BlindedTail_write */ -MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_absolute_expiry(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCResult_BlindedTailDecodeErrorZ BlindedTail_read(struct LDKu8slice ser); /** - * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the Path, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPrintableString InvoiceRequest_issuer(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void Path_free(struct LDKPath this_obj); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * The list of unblinded hops in this [`Path`]. Must be at least length one. */ -MUST_USE_RES struct LDKCVec_BlindedMessagePathZ InvoiceRequest_paths(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCVec_RouteHopZ Path_get_hops(const struct LDKPath *NONNULL_PTR this_ptr); /** - * The quantity of items supported. + * The list of unblinded hops in this [`Path`]. Must be at least length one. */ -MUST_USE_RES struct LDKQuantity InvoiceRequest_supported_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void Path_set_hops(struct LDKPath *NONNULL_PTR this_ptr, struct LDKCVec_RouteHopZ val); /** - * The public key corresponding to the key used by the recipient to sign invoices. - * - If [`Offer::paths`] is empty, MUST be `Some` and contain the recipient's node id for - * sending an [`InvoiceRequest`]. - * - If [`Offer::paths`] is not empty, MAY be `Some` and contain a transient id. - * - If `None`, the signing pubkey will be the final blinded node id from the - * [`BlindedMessagePath`] in [`Offer::paths`] used to send the [`InvoiceRequest`]. - * - * See also [`Bolt12Invoice::signing_pubkey`]. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice::signing_pubkey`]: crate::offers::invoice::Bolt12Invoice::signing_pubkey + * The blinded path at which this path terminates, if we're sending to one, and its metadata. * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKPublicKey InvoiceRequest_issuer_signing_pubkey(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKBlindedTail Path_get_blinded_tail(const struct LDKPath *NONNULL_PTR this_ptr); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_signing_pubkey`]. + * The blinded path at which this path terminates, if we're sending to one, and its metadata. * - * [`payer_signing_pubkey`]: Self::payer_signing_pubkey + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKu8slice InvoiceRequest_payer_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void Path_set_blinded_tail(struct LDKPath *NONNULL_PTR this_ptr, struct LDKBlindedTail val); /** - * A chain from [`Offer::chains`] that the offer is valid for. + * Constructs a new Path given each field + * + * Note that blinded_tail_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKThirtyTwoBytes InvoiceRequest_chain(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPath Path_new(struct LDKCVec_RouteHopZ hops_arg, struct LDKBlindedTail blinded_tail_arg); /** - * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which - * must be greater than or equal to [`Offer::amount`], converted if necessary. - * - * [`chain`]: Self::chain + * Creates a copy of the Path */ -MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_amount_msats(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKPath Path_clone(const struct LDKPath *NONNULL_PTR orig); /** - * Returns whether an amount was set in the request; otherwise, if [`amount_msats`] is `Some` - * then it was inferred from the [`Offer::amount`] and [`quantity`]. - * - * [`amount_msats`]: Self::amount_msats - * [`quantity`]: Self::quantity + * Generates a non-cryptographic 64-bit hash of the Path. */ -MUST_USE_RES bool InvoiceRequest_has_amount_msats(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +uint64_t Path_hash(const struct LDKPath *NONNULL_PTR o); /** - * Features pertaining to requesting an invoice. + * Checks if two Paths contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequest_invoice_request_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +bool Path_eq(const struct LDKPath *NONNULL_PTR a, const struct LDKPath *NONNULL_PTR b); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * Gets the fees for a given path, excluding any excess paid to the recipient. */ -MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Path_fee_msat(const struct LDKPath *NONNULL_PTR this_arg); /** - * A possibly transient pubkey used to sign the invoice request. + * Gets the total amount paid on this [`Path`], excluding the fees. */ -MUST_USE_RES struct LDKPublicKey InvoiceRequest_payer_signing_pubkey(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Path_final_value_msat(const struct LDKPath *NONNULL_PTR this_arg); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Gets the final hop's CLTV expiry delta. */ -MUST_USE_RES struct LDKPrintableString InvoiceRequest_payer_note(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u32Z Path_final_cltv_expiry_delta(const struct LDKPath *NONNULL_PTR this_arg); /** - * If the [`Offer`] was sourced from a BIP 353 Human Readable Name, this should be set by the - * builder to indicate the original [`HumanReadableName`] which was resolved. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the Route, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKHumanReadableName InvoiceRequest_offer_from_hrn(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void Route_free(struct LDKRoute this_obj); /** - * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the - * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. - * - * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned - * creation time is used for the `created_at` parameter. - * - * [`Duration`]: core::time::Duration + * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no + * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be + * the same. */ -MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ InvoiceRequest_respond_with(const struct LDKInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); +struct LDKCVec_PathZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); /** - * Creates an [`InvoiceBuilder`] for the request with the given required fields. - * - * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after - * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. - *Useful for non-`std` builds where [`std::time::SystemTime`] is not available. - * - * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment - * for the invoice. - * - * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It - * must contain one or more elements ordered from most-preferred to least-preferred, if there's - * a preference. Note, however, that any privacy is lost if a public node id was used for - * [`Offer::issuer_signing_pubkey`]. - * - * Errors if the request contains unknown required features. + * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no + * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be + * the same. + */ +void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_PathZ val); + +/** + * The `route_params` parameter passed to [`find_route`]. * - * # Note + * This is used by `ChannelManager` to track information which may be required for retries. * - * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], - * then first use [`InvoiceRequest::verify_using_metadata`] or - * [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods - * instead. + * Will be `None` for objects serialized with LDK versions prior to 0.0.117. * - * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at - * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ InvoiceRequest_respond_with_no_std(const struct LDKInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); +struct LDKRouteParameters Route_get_route_params(const struct LDKRoute *NONNULL_PTR this_ptr); /** - * Verifies that the request was for an offer created using the given key by checking the - * metadata from the offer. + * The `route_params` parameter passed to [`find_route`]. * - * Returns the verified request which contains the derived keys needed to sign a - * [`Bolt12Invoice`] for the request if they could be extracted from the metadata. + * This is used by `ChannelManager` to track information which may be required for retries. * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * Will be `None` for objects serialized with LDK versions prior to 0.0.117. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_VerifiedInvoiceRequestNoneZ InvoiceRequest_verify_using_metadata(struct LDKInvoiceRequest this_arg, const struct LDKExpandedKey *NONNULL_PTR key); +void Route_set_route_params(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKRouteParameters val); /** - * Verifies that the request was for an offer created using the given key by checking a nonce - * included with the [`BlindedMessagePath`] for which the request was sent through. - * - * Returns the verified request which contains the derived keys needed to sign a - * [`Bolt12Invoice`] for the request if they could be extracted from the metadata. + * Constructs a new Route given each field * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * Note that route_params_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_VerifiedInvoiceRequestNoneZ InvoiceRequest_verify_using_recipient_data(struct LDKInvoiceRequest this_arg, struct LDKNonce nonce, const struct LDKExpandedKey *NONNULL_PTR key); +MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_PathZ paths_arg, struct LDKRouteParameters route_params_arg); /** - * Signature of the invoice request using [`payer_signing_pubkey`]. - * - * [`payer_signing_pubkey`]: Self::payer_signing_pubkey + * Creates a copy of the Route */ -MUST_USE_RES struct LDKSchnorrSignature InvoiceRequest_signature(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); /** - * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). - * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) - * for the selected chain. + * Generates a non-cryptographic 64-bit hash of the Route. */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ VerifiedInvoiceRequest_chains(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o); /** - * Opaque bytes set by the originator. Useful for authentication and validating fields since it - * is reflected in `invoice_request` messages along with all the other fields from the `offer`. + * Checks if two Routes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ VerifiedInvoiceRequest_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNULL_PTR b); /** - * The minimum amount required for a successful payment of a single item. + * Returns the total amount of fees paid on this [`Route`]. + * + * For objects serialized with LDK 0.0.117 and after, this includes any extra payment made to + * the recipient, which can happen in excess of the amount passed to [`find_route`] via + * [`RouteParameters::final_value_msat`], if we had to reach the [`htlc_minimum_msat`] limits. + * + * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message */ -MUST_USE_RES struct LDKCOption_AmountZ VerifiedInvoiceRequest_amount(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Route_get_total_fees(const struct LDKRoute *NONNULL_PTR this_arg); /** - * A complete description of the purpose of the payment. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. + * Returns the total amount paid on this [`Route`], excluding the fees. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Might be more than requested as part of the given [`RouteParameters::final_value_msat`] if + * we had to reach the [`htlc_minimum_msat`] limits. + * + * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message */ -MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_description(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg); /** - * Features pertaining to the offer. + * Get the string representation of a Route object */ -MUST_USE_RES struct LDKOfferFeatures VerifiedInvoiceRequest_offer_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKStr Route_to_str(const struct LDKRoute *NONNULL_PTR o); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * If `None`, the offer does not expire. + * Serialize the Route object into a byte array which can be read by Route_read */ -MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_absolute_expiry(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); /** - * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Read a Route from a byte array, created by Route_write */ -MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_issuer(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * Frees any resources used by the RouteParameters, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCVec_BlindedMessagePathZ VerifiedInvoiceRequest_paths(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +void RouteParameters_free(struct LDKRouteParameters this_obj); /** - * The quantity of items supported. + * The parameters of the failed payment path. */ -MUST_USE_RES struct LDKQuantity VerifiedInvoiceRequest_supported_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKPaymentParameters RouteParameters_get_payment_params(const struct LDKRouteParameters *NONNULL_PTR this_ptr); /** - * The public key corresponding to the key used by the recipient to sign invoices. - * - If [`Offer::paths`] is empty, MUST be `Some` and contain the recipient's node id for - * sending an [`InvoiceRequest`]. - * - If [`Offer::paths`] is not empty, MAY be `Some` and contain a transient id. - * - If `None`, the signing pubkey will be the final blinded node id from the - * [`BlindedMessagePath`] in [`Offer::paths`] used to send the [`InvoiceRequest`]. - * - * See also [`Bolt12Invoice::signing_pubkey`]. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice::signing_pubkey`]: crate::offers::invoice::Bolt12Invoice::signing_pubkey - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The parameters of the failed payment path. */ -MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_issuer_signing_pubkey(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +void RouteParameters_set_payment_params(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_signing_pubkey`]. - * - * [`payer_signing_pubkey`]: Self::payer_signing_pubkey + * The amount in msats sent on the failed payment path. */ -MUST_USE_RES struct LDKu8slice VerifiedInvoiceRequest_payer_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +uint64_t RouteParameters_get_final_value_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); + +/** + * The amount in msats sent on the failed payment path. + */ +void RouteParameters_set_final_value_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * A chain from [`Offer::chains`] that the offer is valid for. + * The maximum total fees, in millisatoshi, that may accrue during route finding. + * + * This limit also applies to the total fees that may arise while retrying failed payment + * paths. + * + * Note that values below a few sats may result in some paths being spuriously ignored. */ -MUST_USE_RES struct LDKThirtyTwoBytes VerifiedInvoiceRequest_chain(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCOption_u64Z RouteParameters_get_max_total_routing_fee_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); /** - * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which - * must be greater than or equal to [`Offer::amount`], converted if necessary. + * The maximum total fees, in millisatoshi, that may accrue during route finding. * - * [`chain`]: Self::chain + * This limit also applies to the total fees that may arise while retrying failed payment + * paths. + * + * Note that values below a few sats may result in some paths being spuriously ignored. */ -MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_amount_msats(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +void RouteParameters_set_max_total_routing_fee_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Returns whether an amount was set in the request; otherwise, if [`amount_msats`] is `Some` - * then it was inferred from the [`Offer::amount`] and [`quantity`]. - * - * [`amount_msats`]: Self::amount_msats - * [`quantity`]: Self::quantity + * Constructs a new RouteParameters given each field */ -MUST_USE_RES bool VerifiedInvoiceRequest_has_amount_msats(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPaymentParameters payment_params_arg, uint64_t final_value_msat_arg, struct LDKCOption_u64Z max_total_routing_fee_msat_arg); /** - * Features pertaining to requesting an invoice. + * Creates a copy of the RouteParameters */ -MUST_USE_RES struct LDKInvoiceRequestFeatures VerifiedInvoiceRequest_invoice_request_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKRouteParameters RouteParameters_clone(const struct LDKRouteParameters *NONNULL_PTR orig); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * Generates a non-cryptographic 64-bit hash of the RouteParameters. */ -MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +uint64_t RouteParameters_hash(const struct LDKRouteParameters *NONNULL_PTR o); /** - * A possibly transient pubkey used to sign the invoice request. + * Checks if two RouteParameterss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_payer_signing_pubkey(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +bool RouteParameters_eq(const struct LDKRouteParameters *NONNULL_PTR a, const struct LDKRouteParameters *NONNULL_PTR b); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. + * Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats */ -MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_payer_note(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRouteParameters RouteParameters_from_payment_params_and_value(struct LDKPaymentParameters payment_params, uint64_t final_value_msat); /** - * If the [`Offer`] was sourced from a BIP 353 Human Readable Name, this should be set by the - * builder to indicate the original [`HumanReadableName`] which was resolved. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Sets the maximum number of hops that can be included in a payment path, based on the provided + * [`RecipientOnionFields`] and blinded paths. */ -MUST_USE_RES struct LDKHumanReadableName VerifiedInvoiceRequest_offer_from_hrn(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ RouteParameters_set_max_path_length(struct LDKRouteParameters *NONNULL_PTR this_arg, const struct LDKRecipientOnionFields *NONNULL_PTR recipient_onion, bool is_keysend, uint32_t best_block_height); /** - * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the - * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. - * - * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned - * creation time is used for the `created_at` parameter. - * - * [`Duration`]: core::time::Duration + * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read */ -MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_with(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); +struct LDKCVec_u8Z RouteParameters_write(const struct LDKRouteParameters *NONNULL_PTR obj); /** - * Creates an [`InvoiceBuilder`] for the request with the given required fields. - * - * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after - * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. - *Useful for non-`std` builds where [`std::time::SystemTime`] is not available. - * - * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment - * for the invoice. - * - * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It - * must contain one or more elements ordered from most-preferred to least-preferred, if there's - * a preference. Note, however, that any privacy is lost if a public node id was used for - * [`Offer::issuer_signing_pubkey`]. - * - * Errors if the request contains unknown required features. - * - * # Note - * - * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], - * then first use [`InvoiceRequest::verify_using_metadata`] or - * [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods - * instead. - * - * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at - * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey + * Read a RouteParameters from a byte array, created by RouteParameters_write */ -MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_with_no_std(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); +struct LDKCResult_RouteParametersDecodeErrorZ RouteParameters_read(struct LDKu8slice ser); /** - * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses - * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use - * the same [`ExpandedKey`] as the one used to create the offer. - * - * See [`InvoiceRequest::respond_with`] for further details. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_using_derived_keys(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); +void PaymentParameters_free(struct LDKPaymentParameters this_obj); /** - * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses - * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use - * the same [`ExpandedKey`] as the one used to create the offer. - * - * See [`InvoiceRequest::respond_with_no_std`] for further details. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * Information about the payee, such as their features and route hints for their channels. */ -MUST_USE_RES struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_using_derived_keys_no_std(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); +struct LDKPayee PaymentParameters_get_payee(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read + * Information about the payee, such as their features and route hints for their channels. */ -struct LDKCVec_u8Z UnsignedInvoiceRequest_write(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR obj); +void PaymentParameters_set_payee(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKPayee val); /** - * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read + * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. */ -struct LDKCVec_u8Z InvoiceRequest_write(const struct LDKInvoiceRequest *NONNULL_PTR obj); +struct LDKCOption_u64Z PaymentParameters_get_expiry_time(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Read a InvoiceRequest from a byte array, created by InvoiceRequest_write + * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. */ -struct LDKCResult_InvoiceRequestDecodeErrorZ InvoiceRequest_read(struct LDKu8slice ser); +void PaymentParameters_set_expiry_time(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Frees any resources used by the InvoiceRequestFields, if is_owned is set and inner is non-NULL. + * The maximum total CLTV delta we accept for the route. + * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. */ -void InvoiceRequestFields_free(struct LDKInvoiceRequestFields this_obj); +uint32_t PaymentParameters_get_max_total_cltv_expiry_delta(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * A possibly transient pubkey used to sign the invoice request. + * The maximum total CLTV delta we accept for the route. + * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. */ -struct LDKPublicKey InvoiceRequestFields_get_payer_signing_pubkey(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); +void PaymentParameters_set_max_total_cltv_expiry_delta(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint32_t val); /** - * A possibly transient pubkey used to sign the invoice request. + * The maximum number of paths that may be used by (MPP) payments. + * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. */ -void InvoiceRequestFields_set_payer_signing_pubkey(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint8_t PaymentParameters_get_max_path_count(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * The maximum number of paths that may be used by (MPP) payments. + * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. */ -struct LDKCOption_u64Z InvoiceRequestFields_get_quantity(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); +void PaymentParameters_set_max_path_count(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * The maximum number of [`Path::hops`] in any returned path. + * Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. */ -void InvoiceRequestFields_set_quantity(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +uint8_t PaymentParameters_get_max_path_length(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. Truncated to [`PAYER_NOTE_LIMIT`] characters. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The maximum number of [`Path::hops`] in any returned path. + * Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. */ -struct LDKUntrustedString InvoiceRequestFields_get_payer_note_truncated(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); +void PaymentParameters_set_max_path_length(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. Truncated to [`PAYER_NOTE_LIMIT`] characters. + * Selects the maximum share of a channel's total capacity which will be sent over a channel, + * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas + * a lower value prefers to send larger MPP parts, potentially saturating channels and + * increasing failure probability for those paths. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that this restriction will be relaxed during pathfinding after paths which meet this + * restriction have been found. While paths which meet this criteria will be searched for, it + * is ultimately up to the scorer to select them over other paths. + * + * A value of 0 will allow payments up to and including a channel's total announced usable + * capacity, a value of one will only use up to half its capacity, two 1/4, etc. + * + * Default value: 2 */ -void InvoiceRequestFields_set_payer_note_truncated(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKUntrustedString val); +uint8_t PaymentParameters_get_max_channel_saturation_power_of_half(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * The Human Readable Name which the sender indicated they were paying to. + * Selects the maximum share of a channel's total capacity which will be sent over a channel, + * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas + * a lower value prefers to send larger MPP parts, potentially saturating channels and + * increasing failure probability for those paths. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that this restriction will be relaxed during pathfinding after paths which meet this + * restriction have been found. While paths which meet this criteria will be searched for, it + * is ultimately up to the scorer to select them over other paths. + * + * A value of 0 will allow payments up to and including a channel's total announced usable + * capacity, a value of one will only use up to half its capacity, two 1/4, etc. + * + * Default value: 2 */ -struct LDKHumanReadableName InvoiceRequestFields_get_human_readable_name(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); +void PaymentParameters_set_max_channel_saturation_power_of_half(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); /** - * The Human Readable Name which the sender indicated they were paying to. + * A list of SCIDs which this payment was previously attempted over and which caused the + * payment to fail. Future attempts for the same payment shouldn't be relayed through any of + * these SCIDs. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Returns a copy of the field. */ -void InvoiceRequestFields_set_human_readable_name(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKHumanReadableName val); +struct LDKCVec_u64Z PaymentParameters_get_previously_failed_channels(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Constructs a new InvoiceRequestFields given each field + * A list of SCIDs which this payment was previously attempted over and which caused the + * payment to fail. Future attempts for the same payment shouldn't be relayed through any of + * these SCIDs. + */ +void PaymentParameters_set_previously_failed_channels(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); + +/** + * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this + * payment was previously attempted over and which caused the payment to fail. Future attempts + * for the same payment shouldn't be relayed through any of these blinded paths. * - * Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None - * Note that human_readable_name_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Returns a copy of the field. */ -MUST_USE_RES struct LDKInvoiceRequestFields InvoiceRequestFields_new(struct LDKPublicKey payer_signing_pubkey_arg, struct LDKCOption_u64Z quantity_arg, struct LDKUntrustedString payer_note_truncated_arg, struct LDKHumanReadableName human_readable_name_arg); +struct LDKCVec_u64Z PaymentParameters_get_previously_failed_blinded_path_idxs(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Creates a copy of the InvoiceRequestFields + * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this + * payment was previously attempted over and which caused the payment to fail. Future attempts + * for the same payment shouldn't be relayed through any of these blinded paths. */ -struct LDKInvoiceRequestFields InvoiceRequestFields_clone(const struct LDKInvoiceRequestFields *NONNULL_PTR orig); +void PaymentParameters_set_previously_failed_blinded_path_idxs(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Checks if two InvoiceRequestFieldss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constructs a new PaymentParameters given each field */ -bool InvoiceRequestFields_eq(const struct LDKInvoiceRequestFields *NONNULL_PTR a, const struct LDKInvoiceRequestFields *NONNULL_PTR b); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPayee payee_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg, uint8_t max_path_count_arg, uint8_t max_path_length_arg, uint8_t max_channel_saturation_power_of_half_arg, struct LDKCVec_u64Z previously_failed_channels_arg, struct LDKCVec_u64Z previously_failed_blinded_path_idxs_arg); /** - * Serialize the InvoiceRequestFields object into a byte array which can be read by InvoiceRequestFields_read + * Creates a copy of the PaymentParameters */ -struct LDKCVec_u8Z InvoiceRequestFields_write(const struct LDKInvoiceRequestFields *NONNULL_PTR obj); +struct LDKPaymentParameters PaymentParameters_clone(const struct LDKPaymentParameters *NONNULL_PTR orig); /** - * Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write + * Generates a non-cryptographic 64-bit hash of the PaymentParameters. */ -struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ InvoiceRequestFields_read(struct LDKu8slice ser); +uint64_t PaymentParameters_hash(const struct LDKPaymentParameters *NONNULL_PTR o); /** - * Frees any resources used by the TaggedHash, if is_owned is set and inner is non-NULL. + * Checks if two PaymentParameterss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void TaggedHash_free(struct LDKTaggedHash this_obj); +bool PaymentParameters_eq(const struct LDKPaymentParameters *NONNULL_PTR a, const struct LDKPaymentParameters *NONNULL_PTR b); /** - * Creates a copy of the TaggedHash + * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read */ -struct LDKTaggedHash TaggedHash_clone(const struct LDKTaggedHash *NONNULL_PTR orig); +struct LDKCVec_u8Z PaymentParameters_write(const struct LDKPaymentParameters *NONNULL_PTR obj); /** - * Returns the digest to sign. + * Read a PaymentParameters from a byte array, created by PaymentParameters_write */ -MUST_USE_RES const uint8_t (*TaggedHash_as_digest(const struct LDKTaggedHash *NONNULL_PTR this_arg))[32]; +struct LDKCResult_PaymentParametersDecodeErrorZ PaymentParameters_read(struct LDKu8slice ser, uint32_t arg); /** - * Returns the tag used in the tagged hash. + * Creates a payee with the node id of the given `pubkey`. + * + * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has + * provided. */ -MUST_USE_RES struct LDKStr TaggedHash_tag(const struct LDKTaggedHash *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_node_id(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta); /** - * Returns the merkle root used in the tagged hash. + * Creates a payee with the node id of the given `pubkey` to use for keysend payments. + * + * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has + * provided. + * + * Note that MPP keysend is not widely supported yet. The `allow_mpp` lets you choose + * whether your router will be allowed to find a multi-part route for this payment. If you + * set `allow_mpp` to true, you should ensure a payment secret is set on send, likely via + * [`RecipientOnionFields::secret_only`]. + * + * [`RecipientOnionFields::secret_only`]: crate::ln::channelmanager::RecipientOnionFields::secret_only */ -MUST_USE_RES struct LDKThirtyTwoBytes TaggedHash_merkle_root(const struct LDKTaggedHash *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_for_keysend(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta, bool allow_mpp); /** - * Frees any resources used by the SignError + * Creates parameters for paying to a blinded payee from the provided invoice. Sets + * [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and + * [`PaymentParameters::expiry_time`]. */ -void SignError_free(struct LDKSignError this_ptr); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_bolt12_invoice(const struct LDKBolt12Invoice *NONNULL_PTR invoice); /** - * Creates a copy of the SignError + * Creates parameters for paying to a blinded payee from the provided blinded route hints. */ -struct LDKSignError SignError_clone(const struct LDKSignError *NONNULL_PTR orig); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_blinded(struct LDKCVec_BlindedPaymentPathZ blinded_route_hints); /** - * Utility method to constructs a new Signing-variant SignError + * Frees any resources used by the Payee */ -struct LDKSignError SignError_signing(void); +void Payee_free(struct LDKPayee this_ptr); /** - * Utility method to constructs a new Verification-variant SignError + * Creates a copy of the Payee */ -struct LDKSignError SignError_verification(enum LDKSecp256k1Error a); +struct LDKPayee Payee_clone(const struct LDKPayee *NONNULL_PTR orig); /** - * Frees any resources used by the Nonce, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Blinded-variant Payee */ -void Nonce_free(struct LDKNonce this_obj); +struct LDKPayee Payee_blinded(struct LDKCVec_BlindedPaymentPathZ route_hints, struct LDKBolt12InvoiceFeatures features); /** - * Creates a copy of the Nonce + * Utility method to constructs a new Clear-variant Payee */ -struct LDKNonce Nonce_clone(const struct LDKNonce *NONNULL_PTR orig); +struct LDKPayee Payee_clear(struct LDKPublicKey node_id, struct LDKCVec_RouteHintZ route_hints, struct LDKBolt11InvoiceFeatures features, uint32_t final_cltv_expiry_delta); /** - * Checks if two Nonces contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Generates a non-cryptographic 64-bit hash of the Payee. */ -bool Nonce_eq(const struct LDKNonce *NONNULL_PTR a, const struct LDKNonce *NONNULL_PTR b); +uint64_t Payee_hash(const struct LDKPayee *NONNULL_PTR o); /** - * Creates a `Nonce` from the given [`EntropySource`]. + * Checks if two Payees contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKNonce Nonce_from_entropy_source(struct LDKEntropySource entropy_source); +bool Payee_eq(const struct LDKPayee *NONNULL_PTR a, const struct LDKPayee *NONNULL_PTR b); /** - * Returns a slice of the underlying bytes of size [`Nonce::LENGTH`]. + * Serialize the RouteHint object into a byte array which can be read by RouteHint_read */ -MUST_USE_RES struct LDKu8slice Nonce_as_slice(const struct LDKNonce *NONNULL_PTR this_arg); +struct LDKCVec_u8Z RouteHint_write(const struct LDKRouteHint *NONNULL_PTR obj); /** - * Serialize the Nonce object into a byte array which can be read by Nonce_read + * Read a RouteHint from a byte array, created by RouteHint_write */ -struct LDKCVec_u8Z Nonce_write(const struct LDKNonce *NONNULL_PTR obj); +struct LDKCResult_RouteHintDecodeErrorZ RouteHint_read(struct LDKu8slice ser); /** - * Read a Nonce from a byte array, created by Nonce_write + * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read */ -struct LDKCResult_NonceDecodeErrorZ Nonce_read(struct LDKu8slice ser); +struct LDKCVec_u8Z RouteHintHop_write(const struct LDKRouteHintHop *NONNULL_PTR obj); /** - * Frees any resources used by the Bolt12ParseError, if is_owned is set and inner is non-NULL. + * Read a RouteHintHop from a byte array, created by RouteHintHop_write */ -void Bolt12ParseError_free(struct LDKBolt12ParseError this_obj); +struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice ser); /** - * Creates a copy of the Bolt12ParseError + * Frees any resources used by the FirstHopCandidate, if is_owned is set and inner is non-NULL. */ -struct LDKBolt12ParseError Bolt12ParseError_clone(const struct LDKBolt12ParseError *NONNULL_PTR orig); +void FirstHopCandidate_free(struct LDKFirstHopCandidate this_obj); /** - * Creates a copy of the Bolt12SemanticError + * Creates a copy of the FirstHopCandidate */ -enum LDKBolt12SemanticError Bolt12SemanticError_clone(const enum LDKBolt12SemanticError *NONNULL_PTR orig); +struct LDKFirstHopCandidate FirstHopCandidate_clone(const struct LDKFirstHopCandidate *NONNULL_PTR orig); /** - * Utility method to constructs a new AlreadyExpired-variant Bolt12SemanticError + * Frees any resources used by the PublicHopCandidate, if is_owned is set and inner is non-NULL. */ -enum LDKBolt12SemanticError Bolt12SemanticError_already_expired(void); +void PublicHopCandidate_free(struct LDKPublicHopCandidate this_obj); /** - * Utility method to constructs a new UnsupportedChain-variant Bolt12SemanticError + * The short channel ID of the channel, i.e. the identifier by which we refer to this + * channel. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_chain(void); +uint64_t PublicHopCandidate_get_short_channel_id(const struct LDKPublicHopCandidate *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new UnexpectedChain-variant Bolt12SemanticError + * The short channel ID of the channel, i.e. the identifier by which we refer to this + * channel. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_chain(void); +void PublicHopCandidate_set_short_channel_id(struct LDKPublicHopCandidate *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new MissingAmount-variant Bolt12SemanticError + * Creates a copy of the PublicHopCandidate */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_amount(void); +struct LDKPublicHopCandidate PublicHopCandidate_clone(const struct LDKPublicHopCandidate *NONNULL_PTR orig); /** - * Utility method to constructs a new InvalidAmount-variant Bolt12SemanticError + * Frees any resources used by the PrivateHopCandidate, if is_owned is set and inner is non-NULL. */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_amount(void); +void PrivateHopCandidate_free(struct LDKPrivateHopCandidate this_obj); /** - * Utility method to constructs a new InsufficientAmount-variant Bolt12SemanticError + * Creates a copy of the PrivateHopCandidate */ -enum LDKBolt12SemanticError Bolt12SemanticError_insufficient_amount(void); +struct LDKPrivateHopCandidate PrivateHopCandidate_clone(const struct LDKPrivateHopCandidate *NONNULL_PTR orig); /** - * Utility method to constructs a new UnexpectedAmount-variant Bolt12SemanticError + * Frees any resources used by the BlindedPathCandidate, if is_owned is set and inner is non-NULL. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_amount(void); +void BlindedPathCandidate_free(struct LDKBlindedPathCandidate this_obj); /** - * Utility method to constructs a new UnsupportedCurrency-variant Bolt12SemanticError + * Creates a copy of the BlindedPathCandidate */ -enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_currency(void); +struct LDKBlindedPathCandidate BlindedPathCandidate_clone(const struct LDKBlindedPathCandidate *NONNULL_PTR orig); /** - * Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12SemanticError + * Frees any resources used by the OneHopBlindedPathCandidate, if is_owned is set and inner is non-NULL. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unknown_required_features(void); +void OneHopBlindedPathCandidate_free(struct LDKOneHopBlindedPathCandidate this_obj); /** - * Utility method to constructs a new UnexpectedFeatures-variant Bolt12SemanticError + * Creates a copy of the OneHopBlindedPathCandidate */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_features(void); +struct LDKOneHopBlindedPathCandidate OneHopBlindedPathCandidate_clone(const struct LDKOneHopBlindedPathCandidate *NONNULL_PTR orig); /** - * Utility method to constructs a new MissingDescription-variant Bolt12SemanticError + * Frees any resources used by the CandidateRouteHop */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_description(void); +void CandidateRouteHop_free(struct LDKCandidateRouteHop this_ptr); /** - * Utility method to constructs a new MissingIssuerSigningPubkey-variant Bolt12SemanticError + * Creates a copy of the CandidateRouteHop */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_issuer_signing_pubkey(void); +struct LDKCandidateRouteHop CandidateRouteHop_clone(const struct LDKCandidateRouteHop *NONNULL_PTR orig); /** - * Utility method to constructs a new UnexpectedIssuerSigningPubkey-variant Bolt12SemanticError + * Utility method to constructs a new FirstHop-variant CandidateRouteHop */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_issuer_signing_pubkey(void); +struct LDKCandidateRouteHop CandidateRouteHop_first_hop(struct LDKFirstHopCandidate a); /** - * Utility method to constructs a new MissingQuantity-variant Bolt12SemanticError + * Utility method to constructs a new PublicHop-variant CandidateRouteHop */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_quantity(void); +struct LDKCandidateRouteHop CandidateRouteHop_public_hop(struct LDKPublicHopCandidate a); /** - * Utility method to constructs a new InvalidQuantity-variant Bolt12SemanticError + * Utility method to constructs a new PrivateHop-variant CandidateRouteHop */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_quantity(void); +struct LDKCandidateRouteHop CandidateRouteHop_private_hop(struct LDKPrivateHopCandidate a); /** - * Utility method to constructs a new UnexpectedQuantity-variant Bolt12SemanticError + * Utility method to constructs a new Blinded-variant CandidateRouteHop */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_quantity(void); +struct LDKCandidateRouteHop CandidateRouteHop_blinded(struct LDKBlindedPathCandidate a); /** - * Utility method to constructs a new InvalidMetadata-variant Bolt12SemanticError + * Utility method to constructs a new OneHopBlinded-variant CandidateRouteHop */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_metadata(void); +struct LDKCandidateRouteHop CandidateRouteHop_one_hop_blinded(struct LDKOneHopBlindedPathCandidate a); /** - * Utility method to constructs a new UnexpectedMetadata-variant Bolt12SemanticError + * Returns the globally unique short channel ID for this hop, if one is known. + * + * This only returns `Some` if the channel is public (either our own, or one we've learned + * from the public network graph), and thus the short channel ID we have for this channel is + * globally unique and identifies this channel in a global namespace. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_metadata(void); +MUST_USE_RES struct LDKCOption_u64Z CandidateRouteHop_globally_unique_short_channel_id(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * Utility method to constructs a new MissingPayerMetadata-variant Bolt12SemanticError + * Returns the required difference in HTLC CLTV expiry between the [`Self::source`] and the + * next-hop for an HTLC taking this hop. + * + * This is the time that the node(s) in this hop have to claim the HTLC on-chain if the + * next-hop goes on chain with a payment preimage. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_metadata(void); +MUST_USE_RES uint32_t CandidateRouteHop_cltv_expiry_delta(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * Utility method to constructs a new MissingPayerSigningPubkey-variant Bolt12SemanticError + * Returns the minimum amount that can be sent over this hop, in millisatoshis. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_signing_pubkey(void); +MUST_USE_RES uint64_t CandidateRouteHop_htlc_minimum_msat(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * Utility method to constructs a new DuplicatePaymentId-variant Bolt12SemanticError + * Returns the fees that must be paid to route an HTLC over this channel. */ -enum LDKBolt12SemanticError Bolt12SemanticError_duplicate_payment_id(void); +MUST_USE_RES struct LDKRoutingFees CandidateRouteHop_fees(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * Utility method to constructs a new MissingPaths-variant Bolt12SemanticError + * Returns the source node id of current hop. + * + * Source node id refers to the node forwarding the HTLC through this hop. + * + * For [`Self::FirstHop`] we return payer's node id. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_paths(void); +MUST_USE_RES struct LDKNodeId CandidateRouteHop_source(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UnexpectedPaths-variant Bolt12SemanticError + * Returns the target node id of this hop, if known. + * + * Target node id refers to the node receiving the HTLC after this hop. + * + * For [`Self::Blinded`] we return `None` because the ultimate destination after the blinded + * path is unknown. + * + * For [`Self::OneHopBlinded`] we return `None` because the target is the same as the source, + * and such a return value would be somewhat nonsensical. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_paths(void); +MUST_USE_RES struct LDKNodeId CandidateRouteHop_target(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidPayInfo-variant Bolt12SemanticError + * Finds a route from us (payer) to the given target node (payee). + * + * If the payee provided features in their invoice, they should be provided via the `payee` field + * in the given [`RouteParameters::payment_params`]. + * Without this, MPP will only be used if the payee's features are available in the network graph. + * + * Private routing paths between a public node and the target may be included in the `payee` field + * of [`RouteParameters::payment_params`]. + * + * If some channels aren't announced, it may be useful to fill in `first_hops` with the results + * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels + * from `network_graph` will be ignored, and only those in `first_hops` will be used. + * + * The fees on channels from us to the next hop are ignored as they are assumed to all be equal. + * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` / + * `htlc_maximum_msat` *are* checked as they may change based on the receiving node. + * + * # Panics + * + * Panics if first_hops contains channels without `short_channel_id`s; + * [`ChannelManager::list_usable_channels`] will never include such channels. + * + * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + * + * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_pay_info(void); +struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScoreLookUp *NONNULL_PTR scorer, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params, const uint8_t (*random_seed_bytes)[32]); /** - * Utility method to constructs a new MissingCreationTime-variant Bolt12SemanticError + * Construct a route from us (payer) to the target node (payee) via the given hops (which should + * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path. + * + * Re-uses logic from `find_route`, so the restrictions described there also apply here. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_creation_time(void); +struct LDKCResult_RouteLightningErrorZ build_route_from_hops(struct LDKPublicKey our_node_pubkey, struct LDKCVec_PublicKeyZ hops, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, const uint8_t (*random_seed_bytes)[32]); /** - * Utility method to constructs a new MissingPaymentHash-variant Bolt12SemanticError + * Calls the free function if one is set */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_payment_hash(void); +void ScoreLookUp_free(struct LDKScoreLookUp this_ptr); /** - * Utility method to constructs a new UnexpectedPaymentHash-variant Bolt12SemanticError + * Calls the free function if one is set */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_payment_hash(void); +void ScoreUpdate_free(struct LDKScoreUpdate this_ptr); /** - * Utility method to constructs a new MissingSigningPubkey-variant Bolt12SemanticError + * Calls the free function if one is set */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_signing_pubkey(void); +void Score_free(struct LDKScore this_ptr); /** - * Utility method to constructs a new InvalidSigningPubkey-variant Bolt12SemanticError + * Calls the free function if one is set */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_signing_pubkey(void); +void LockableScore_free(struct LDKLockableScore this_ptr); /** - * Utility method to constructs a new MissingSignature-variant Bolt12SemanticError + * Calls the free function if one is set */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_signature(void); +void WriteableScore_free(struct LDKWriteableScore this_ptr); /** - * Utility method to constructs a new UnexpectedHumanReadableName-variant Bolt12SemanticError + * Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_human_readable_name(void); +void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj); /** - * Frees any resources used by the RefundMaybeWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. + * Constructs a new LockableScore which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is */ -void RefundMaybeWithDerivedMetadataBuilder_free(struct LDKRefundMaybeWithDerivedMetadataBuilder this_obj); +struct LDKLockableScore MultiThreadedLockableScore_as_LockableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); /** - * Creates a copy of the RefundMaybeWithDerivedMetadataBuilder + * Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read */ -struct LDKRefundMaybeWithDerivedMetadataBuilder RefundMaybeWithDerivedMetadataBuilder_clone(const struct LDKRefundMaybeWithDerivedMetadataBuilder *NONNULL_PTR orig); +struct LDKCVec_u8Z MultiThreadedLockableScore_write(const struct LDKMultiThreadedLockableScore *NONNULL_PTR obj); /** - * Creates a new builder for a refund using the `signing_pubkey` for the public node id to send - * to if no [`Refund::paths`] are set. Otherwise, `signing_pubkey` may be a transient pubkey. - * - * Additionally, sets the required (empty) [`Refund::description`], [`Refund::payer_metadata`], - * and [`Refund::amount_msats`]. - * - * # Note - * - * If constructing a [`Refund`] for use with a [`ChannelManager`], use - * [`ChannelManager::create_refund_builder`] instead of [`RefundBuilder::new`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelManager::create_refund_builder`]: crate::ln::channelmanager::ChannelManager::create_refund_builder + * Constructs a new WriteableScore which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned WriteableScore must be freed before this_arg is */ -MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_new(struct LDKCVec_u8Z metadata, struct LDKPublicKey signing_pubkey, uint64_t amount_msats); +struct LDKWriteableScore MultiThreadedLockableScore_as_WriteableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); /** - * Similar to [`RefundBuilder::new`] except, if [`RefundBuilder::path`] is called, the payer id - * is derived from the given [`ExpandedKey`] and nonce. This provides sender privacy by using a - * different payer id for each refund, assuming a different nonce is used. Otherwise, the - * provided `node_id` is used for the payer id. - * - * Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used by - * [`Bolt12Invoice::verify_using_metadata`] to determine if the invoice was produced for the - * refund given an [`ExpandedKey`]. However, if [`RefundBuilder::path`] is called, then the - * metadata must be included in each [`BlindedMessagePath`] instead. In this case, use - * [`Bolt12Invoice::verify_using_payer_data`]. - * - * The `payment_id` is encrypted in the metadata and should be unique. This ensures that only - * one invoice will be paid for the refund and that payments can be uniquely identified. - * - * [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata - * [`Bolt12Invoice::verify_using_payer_data`]: crate::offers::invoice::Bolt12Invoice::verify_using_payer_data - * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey + * Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. */ -MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_deriving_signing_pubkey(struct LDKPublicKey node_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce, uint64_t amount_msats, struct LDKThirtyTwoBytes payment_id); +MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new(struct LDKScore score); /** - * Sets the [`Refund::description`]. - * - * Successive calls to this method will override the previous setting. + * Frees any resources used by the MultiThreadedScoreLockRead, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_description(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr description); +void MultiThreadedScoreLockRead_free(struct LDKMultiThreadedScoreLockRead this_obj); /** - * Sets the [`Refund::absolute_expiry`] as seconds since the Unix epoch. - *Any expiry that has already passed is valid and can be checked for using [`Refund::is_expired`]. - * - * Successive calls to this method will override the previous setting. + * Frees any resources used by the MultiThreadedScoreLockWrite, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_absolute_expiry(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, uint64_t absolute_expiry); +void MultiThreadedScoreLockWrite_free(struct LDKMultiThreadedScoreLockWrite this_obj); /** - * Sets the [`Refund::issuer`]. - * - * Successive calls to this method will override the previous setting. + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_issuer(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr issuer); +struct LDKScoreLookUp MultiThreadedScoreLockRead_as_ScoreLookUp(const struct LDKMultiThreadedScoreLockRead *NONNULL_PTR this_arg); /** - * Adds a blinded path to [`Refund::paths`]. Must include at least one path if only connected - * by private channels or if [`Refund::payer_signing_pubkey`] is not a public node id. - * - * Successive calls to this method will add another blinded path. Caller is responsible for not - * adding duplicate paths. + * Serialize the MultiThreadedScoreLockWrite object into a byte array which can be read by MultiThreadedScoreLockWrite_read */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_path(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKBlindedMessagePath path); +struct LDKCVec_u8Z MultiThreadedScoreLockWrite_write(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR obj); /** - * Sets the [`Refund::chain`] of the given [`Network`] for paying an invoice. If not - * called, [`Network::Bitcoin`] is assumed. - * - * Successive calls to this method will override the previous setting. + * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_chain(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, enum LDKNetwork network); +struct LDKScoreUpdate MultiThreadedScoreLockWrite_as_ScoreUpdate(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR this_arg); /** - * Sets [`Refund::quantity`] of items. This is purely for informational purposes. It is useful - * when the refund pertains to a [`Bolt12Invoice`] that paid for more than one item from an - * [`Offer`] as specified by [`InvoiceRequest::quantity`]. - * - * Successive calls to this method will override the previous setting. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice - * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity - * [`Offer`]: crate::offers::offer::Offer + * Frees any resources used by the ChannelUsage, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_quantity(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, uint64_t quantity); +void ChannelUsage_free(struct LDKChannelUsage this_obj); /** - * Sets the [`Refund::payer_note`]. - * - * Successive calls to this method will override the previous setting. + * The amount to send through the channel, denominated in millisatoshis. */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_payer_note(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr payer_note); +uint64_t ChannelUsage_get_amount_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); /** - * Builds a [`Refund`] after checking for valid semantics. + * The amount to send through the channel, denominated in millisatoshis. */ -MUST_USE_RES struct LDKCResult_RefundBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_build(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg); +void ChannelUsage_set_amount_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the Refund, if is_owned is set and inner is non-NULL. + * Total amount, denominated in millisatoshis, already allocated to send through the channel + * as part of a multi-path payment. */ -void Refund_free(struct LDKRefund this_obj); +uint64_t ChannelUsage_get_inflight_htlc_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); /** - * Creates a copy of the Refund + * Total amount, denominated in millisatoshis, already allocated to send through the channel + * as part of a multi-path payment. */ -struct LDKRefund Refund_clone(const struct LDKRefund *NONNULL_PTR orig); +void ChannelUsage_set_inflight_htlc_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); /** - * A complete description of the purpose of the refund. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. + * The effective capacity of the channel. */ -MUST_USE_RES struct LDKPrintableString Refund_description(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKEffectiveCapacity ChannelUsage_get_effective_capacity(const struct LDKChannelUsage *NONNULL_PTR this_ptr); /** - * Duration since the Unix epoch when an invoice should no longer be sent. - * - * If `None`, the refund does not expire. + * The effective capacity of the channel. */ -MUST_USE_RES struct LDKCOption_u64Z Refund_absolute_expiry(const struct LDKRefund *NONNULL_PTR this_arg); +void ChannelUsage_set_effective_capacity(struct LDKChannelUsage *NONNULL_PTR this_ptr, struct LDKEffectiveCapacity val); /** - * Whether the refund has expired. + * Constructs a new ChannelUsage given each field */ -MUST_USE_RES bool Refund_is_expired(const struct LDKRefund *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelUsage ChannelUsage_new(uint64_t amount_msat_arg, uint64_t inflight_htlc_msat_arg, struct LDKEffectiveCapacity effective_capacity_arg); /** - * Whether the refund has expired given the duration since the Unix epoch. + * Creates a copy of the ChannelUsage */ -MUST_USE_RES bool Refund_is_expired_no_std(const struct LDKRefund *NONNULL_PTR this_arg, uint64_t duration_since_epoch); +struct LDKChannelUsage ChannelUsage_clone(const struct LDKChannelUsage *NONNULL_PTR orig); /** - * The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPrintableString Refund_issuer(const struct LDKRefund *NONNULL_PTR this_arg); +void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj); /** - * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender - * privacy by obfuscating its node id. + * Creates a copy of the FixedPenaltyScorer */ -MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Refund_paths(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKFixedPenaltyScorer FixedPenaltyScorer_clone(const struct LDKFixedPenaltyScorer *NONNULL_PTR orig); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_signing_pubkey`]. - * - * [`payer_signing_pubkey`]: Self::payer_signing_pubkey + * Creates a new scorer using `penalty_msat`. */ -MUST_USE_RES struct LDKu8slice Refund_payer_metadata(const struct LDKRefund *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64_t penalty_msat); /** - * A chain that the refund is valid for. + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is */ -MUST_USE_RES struct LDKThirtyTwoBytes Refund_chain(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKScoreLookUp FixedPenaltyScorer_as_ScoreLookUp(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); /** - * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]). - * - * [`chain`]: Self::chain + * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is */ -MUST_USE_RES uint64_t Refund_amount_msats(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKScoreUpdate FixedPenaltyScorer_as_ScoreUpdate(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); /** - * Features pertaining to requesting an invoice. + * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read */ -MUST_USE_RES struct LDKInvoiceRequestFeatures Refund_features(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); /** - * The quantity of an item that refund is for. + * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write */ -MUST_USE_RES struct LDKCOption_u64Z Refund_quantity(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser, uint64_t arg); /** - * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly - * transient pubkey. - * - * [`paths`]: Self::paths + * Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPublicKey Refund_payer_signing_pubkey(const struct LDKRefund *NONNULL_PTR this_arg); +void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj); /** - * Payer provided note to include in the invoice. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the ProbabilisticScoringFeeParameters, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPrintableString Refund_payer_note(const struct LDKRefund *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_free(struct LDKProbabilisticScoringFeeParameters this_obj); /** - * Generates a non-cryptographic 64-bit hash of the Refund. + * A fixed penalty in msats to apply to each channel. + * + * In testing, a value of roughly 1/10th of [`historical_liquidity_penalty_multiplier_msat`] + * (implying scaling all estimated probabilities down by a factor of ~79%) resulted in the + * most accurate total success probabilities. + * + * Default value: 1,024 msat (i.e. we're willing to pay 1 sat to avoid each additional hop). + * + * [`historical_liquidity_penalty_multiplier_msat`]: Self::historical_liquidity_penalty_multiplier_msat */ -uint64_t Refund_hash(const struct LDKRefund *NONNULL_PTR o); +uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Read a Refund from a byte array, created by Refund_write + * A fixed penalty in msats to apply to each channel. + * + * In testing, a value of roughly 1/10th of [`historical_liquidity_penalty_multiplier_msat`] + * (implying scaling all estimated probabilities down by a factor of ~79%) resulted in the + * most accurate total success probabilities. + * + * Default value: 1,024 msat (i.e. we're willing to pay 1 sat to avoid each additional hop). + * + * [`historical_liquidity_penalty_multiplier_msat`]: Self::historical_liquidity_penalty_multiplier_msat */ -struct LDKCResult_RefundDecodeErrorZ Refund_read(struct LDKu8slice ser); +void ProbabilisticScoringFeeParameters_set_base_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Serialize the Refund object into a byte array which can be read by Refund_read + * A multiplier used with the payment amount to calculate a fixed penalty applied to each + * channel, in excess of the [`base_penalty_msat`]. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^30`ths of the payment amount. + * + * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` + * + * In testing, a value of roughly ~100x (1/10th * 2^10) of + * [`historical_liquidity_penalty_amount_multiplier_msat`] (implying scaling all estimated + * probabilities down by a factor of ~79%) resulted in the most accurate total success + * probabilities. + * + * Default value: 131,072 msat (i.e. we're willing to pay 0.125bps to avoid each additional + * hop). + * + * [`base_penalty_msat`]: Self::base_penalty_msat + * [`historical_liquidity_penalty_amount_multiplier_msat`]: Self::historical_liquidity_penalty_amount_multiplier_msat */ -struct LDKCVec_u8Z Refund_write(const struct LDKRefund *NONNULL_PTR obj); +uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Read a Refund object from a string + * A multiplier used with the payment amount to calculate a fixed penalty applied to each + * channel, in excess of the [`base_penalty_msat`]. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^30`ths of the payment amount. + * + * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` + * + * In testing, a value of roughly ~100x (1/10th * 2^10) of + * [`historical_liquidity_penalty_amount_multiplier_msat`] (implying scaling all estimated + * probabilities down by a factor of ~79%) resulted in the most accurate total success + * probabilities. + * + * Default value: 131,072 msat (i.e. we're willing to pay 0.125bps to avoid each additional + * hop). + * + * [`base_penalty_msat`]: Self::base_penalty_msat + * [`historical_liquidity_penalty_amount_multiplier_msat`]: Self::historical_liquidity_penalty_amount_multiplier_msat */ -struct LDKCResult_RefundBolt12ParseErrorZ Refund_from_str(struct LDKStr s); +void ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Get the string representation of a Refund object + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for a payment, as determined by our latest estimates of the channel's + * liquidity, to determine the liquidity penalty. + * + * The penalty is based in part on the knowledge learned from prior successful and unsuccessful + * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The + * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to + * lower bounding the success probability to `0.01`) when the amount falls within the + * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will + * result in a `u64::max_value` penalty, however. + * + * `-log10(success_probability) * liquidity_penalty_multiplier_msat` + * + * In testing, this scoring model performs much worse than the historical scoring model + * configured with the [`historical_liquidity_penalty_multiplier_msat`] and thus is disabled + * by default. + * + * Default value: 0 msat + * + * [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life + * [`historical_liquidity_penalty_multiplier_msat`]: Self::historical_liquidity_penalty_multiplier_msat */ -struct LDKStr Refund_to_str(const struct LDKRefund *NONNULL_PTR o); +uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Creates a copy of the UtxoLookupError + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for a payment, as determined by our latest estimates of the channel's + * liquidity, to determine the liquidity penalty. + * + * The penalty is based in part on the knowledge learned from prior successful and unsuccessful + * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The + * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to + * lower bounding the success probability to `0.01`) when the amount falls within the + * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will + * result in a `u64::max_value` penalty, however. + * + * `-log10(success_probability) * liquidity_penalty_multiplier_msat` + * + * In testing, this scoring model performs much worse than the historical scoring model + * configured with the [`historical_liquidity_penalty_multiplier_msat`] and thus is disabled + * by default. + * + * Default value: 0 msat + * + * [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life + * [`historical_liquidity_penalty_multiplier_msat`]: Self::historical_liquidity_penalty_multiplier_msat */ -enum LDKUtxoLookupError UtxoLookupError_clone(const enum LDKUtxoLookupError *NONNULL_PTR orig); +void ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new UnknownChain-variant UtxoLookupError + * A multiplier used in conjunction with the payment amount and the negative `log10` of the + * channel's success probability for the total amount flowing over a channel, as determined by + * our latest estimates of the channel's liquidity, to determine the amount penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the + * success probability. + * + * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` + * + * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of + * the amount will result in a penalty of the multiplier. And, as the success probability + * decreases, the negative `log10` weighting will increase dramatically. For higher success + * probabilities, the multiplier will have a decreasing effect as the negative `log10` will + * fall below `1`. + * + * In testing, this scoring model performs much worse than the historical scoring model + * configured with the [`historical_liquidity_penalty_amount_multiplier_msat`] and thus is + * disabled by default. + * + * Default value: 0 msat + * + * [`historical_liquidity_penalty_amount_multiplier_msat`]: Self::historical_liquidity_penalty_amount_multiplier_msat */ -enum LDKUtxoLookupError UtxoLookupError_unknown_chain(void); +uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new UnknownTx-variant UtxoLookupError + * A multiplier used in conjunction with the payment amount and the negative `log10` of the + * channel's success probability for the total amount flowing over a channel, as determined by + * our latest estimates of the channel's liquidity, to determine the amount penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the + * success probability. + * + * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` + * + * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of + * the amount will result in a penalty of the multiplier. And, as the success probability + * decreases, the negative `log10` weighting will increase dramatically. For higher success + * probabilities, the multiplier will have a decreasing effect as the negative `log10` will + * fall below `1`. + * + * In testing, this scoring model performs much worse than the historical scoring model + * configured with the [`historical_liquidity_penalty_amount_multiplier_msat`] and thus is + * disabled by default. + * + * Default value: 0 msat + * + * [`historical_liquidity_penalty_amount_multiplier_msat`]: Self::historical_liquidity_penalty_amount_multiplier_msat */ -enum LDKUtxoLookupError UtxoLookupError_unknown_tx(void); +void ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the UtxoResult + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for the payment, as determined based on the history of our estimates of the + * channel's available liquidity, to determine a penalty. + * + * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using + * only our latest estimate for the current liquidity available in the channel, it estimates + * success probability based on the estimated liquidity available in the channel through + * history. Specifically, every time we update our liquidity bounds on a given channel, we + * track which of several buckets those bounds fall into, exponentially decaying the + * probability of each bucket as new samples are added. + * + * Default value: 10,000 msat (i.e. willing to pay 1 sat to avoid an 80% probability channel, + * or 6 sats to avoid a 25% probability channel). + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat */ -void UtxoResult_free(struct LDKUtxoResult this_ptr); +uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Creates a copy of the UtxoResult + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for the payment, as determined based on the history of our estimates of the + * channel's available liquidity, to determine a penalty. + * + * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using + * only our latest estimate for the current liquidity available in the channel, it estimates + * success probability based on the estimated liquidity available in the channel through + * history. Specifically, every time we update our liquidity bounds on a given channel, we + * track which of several buckets those bounds fall into, exponentially decaying the + * probability of each bucket as new samples are added. + * + * Default value: 10,000 msat (i.e. willing to pay 1 sat to avoid an 80% probability channel, + * or 6 sats to avoid a 25% probability channel). + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat */ -struct LDKUtxoResult UtxoResult_clone(const struct LDKUtxoResult *NONNULL_PTR orig); +void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new Sync-variant UtxoResult + * A multiplier used in conjunction with the payment amount and the negative `log10` of the + * channel's success probability for the total amount flowing over a channel, as determined + * based on the history of our estimates of the channel's available liquidity, to determine a + * penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost for + * large payments. The penalty is computed as the product of this multiplier and `2^20`ths + * of the payment amount, weighted by the negative `log10` of the success probability. + * + * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead + * of using only our latest estimate for the current liquidity available in the channel, it + * estimates success probability based on the estimated liquidity available in the channel + * through history. Specifically, every time we update our liquidity bounds on a given + * channel, we track which of several buckets those bounds fall into, exponentially decaying + * the probability of each bucket as new samples are added. + * + * Default value: 1,250 msat (i.e. willing to pay about 0.125 bps per hop to avoid 78% + * probability channels, or 0.5bps to avoid a 38% probability + * channel). + * + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat */ -struct LDKUtxoResult UtxoResult_sync(struct LDKCResult_TxOutUtxoLookupErrorZ a); +uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Async-variant UtxoResult + * A multiplier used in conjunction with the payment amount and the negative `log10` of the + * channel's success probability for the total amount flowing over a channel, as determined + * based on the history of our estimates of the channel's available liquidity, to determine a + * penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost for + * large payments. The penalty is computed as the product of this multiplier and `2^20`ths + * of the payment amount, weighted by the negative `log10` of the success probability. + * + * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead + * of using only our latest estimate for the current liquidity available in the channel, it + * estimates success probability based on the estimated liquidity available in the channel + * through history. Specifically, every time we update our liquidity bounds on a given + * channel, we track which of several buckets those bounds fall into, exponentially decaying + * the probability of each bucket as new samples are added. + * + * Default value: 1,250 msat (i.e. willing to pay about 0.125 bps per hop to avoid 78% + * probability channels, or 0.5bps to avoid a 38% probability + * channel). + * + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat */ -struct LDKUtxoResult UtxoResult_async(struct LDKUtxoFuture a); +void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Calls the free function if one is set + * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the + * channel's capacity, (ie. htlc_maximum_msat >= 0.5 * channel_capacity) which makes us + * prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially + * as this makes balance discovery attacks harder to execute, thereby creating an incentive + * to restrict `htlc_maximum_msat` and improve privacy. + * + * Default value: 250 msat */ -void UtxoLookup_free(struct LDKUtxoLookup this_ptr); +uint64_t ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UtxoFuture, if is_owned is set and inner is non-NULL. + * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the + * channel's capacity, (ie. htlc_maximum_msat >= 0.5 * channel_capacity) which makes us + * prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially + * as this makes balance discovery attacks harder to execute, thereby creating an incentive + * to restrict `htlc_maximum_msat` and improve privacy. + * + * Default value: 250 msat */ -void UtxoFuture_free(struct LDKUtxoFuture this_obj); +void ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the UtxoFuture + * This penalty is applied when the total amount flowing over a channel exceeds our current + * estimate of the channel's available liquidity. The total amount is the amount of the + * current HTLC plus any HTLCs which we've sent over the same channel. + * + * Note that in this case all other penalties, including the + * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based + * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if + * applicable, are still included in the overall penalty. + * + * If you wish to avoid creating paths with such channels entirely, setting this to a value of + * `u64::max_value()` will guarantee that. + * + * Default value: 1_0000_0000_000 msat (1 Bitcoin) + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * [`base_penalty_msat`]: Self::base_penalty_msat + * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat */ -struct LDKUtxoFuture UtxoFuture_clone(const struct LDKUtxoFuture *NONNULL_PTR orig); +uint64_t ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Builds a new future for later resolution. + * This penalty is applied when the total amount flowing over a channel exceeds our current + * estimate of the channel's available liquidity. The total amount is the amount of the + * current HTLC plus any HTLCs which we've sent over the same channel. + * + * Note that in this case all other penalties, including the + * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based + * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if + * applicable, are still included in the overall penalty. + * + * If you wish to avoid creating paths with such channels entirely, setting this to a value of + * `u64::max_value()` will guarantee that. + * + * Default value: 1_0000_0000_000 msat (1 Bitcoin) + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * [`base_penalty_msat`]: Self::base_penalty_msat + * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat */ -MUST_USE_RES struct LDKUtxoFuture UtxoFuture_new(void); +void ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Resolves this future against the given `graph` and with the given `result`. + * In order to calculate most of the scores above, we must first convert a lower and upper + * bound on the available liquidity in a channel into the probability that we think a payment + * will succeed. That probability is derived from a Probability Density Function for where we + * think the liquidity in a channel likely lies, given such bounds. * - * This is identical to calling [`UtxoFuture::resolve`] with a dummy `gossip`, disabling - * forwarding the validated gossip message onwards to peers. + * If this flag is set, that PDF is simply a constant - we assume that the actual available + * liquidity in a channel is just as likely to be at any point between our lower and upper + * bounds. + * + * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an + * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This + * matches experimental results - most routing nodes do not aggressively rebalance their + * channels and flows in the network are often unbalanced, leaving liquidity usually + * unavailable. * - * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order - * to allow us to interact with peers again, you should call [`PeerManager::process_events`] - * after this. + * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number + * of floating-point multiplications in the hottest routing code, which may lead to routing + * performance degradation on some machines. * - * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high - * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events + * Default value: false */ -void UtxoFuture_resolve_without_forwarding(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, struct LDKCResult_TxOutUtxoLookupErrorZ result); +bool ProbabilisticScoringFeeParameters_get_linear_success_probability(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Resolves this future against the given `graph` and with the given `result`. + * In order to calculate most of the scores above, we must first convert a lower and upper + * bound on the available liquidity in a channel into the probability that we think a payment + * will succeed. That probability is derived from a Probability Density Function for where we + * think the liquidity in a channel likely lies, given such bounds. * - * The given `gossip` is used to broadcast any validated messages onwards to all peers which - * have available buffer space. + * If this flag is set, that PDF is simply a constant - we assume that the actual available + * liquidity in a channel is just as likely to be at any point between our lower and upper + * bounds. * - * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order - * to allow us to interact with peers again, you should call [`PeerManager::process_events`] - * after this. + * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an + * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This + * matches experimental results - most routing nodes do not aggressively rebalance their + * channels and flows in the network are often unbalanced, leaving liquidity usually + * unavailable. * - * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high - * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events - */ -void UtxoFuture_resolve(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, const struct LDKP2PGossipSync *NONNULL_PTR gossip, struct LDKCResult_TxOutUtxoLookupErrorZ result); - -/** - * Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL. + * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number + * of floating-point multiplications in the hottest routing code, which may lead to routing + * performance degradation on some machines. + * + * Default value: false */ -void NodeId_free(struct LDKNodeId this_obj); +void ProbabilisticScoringFeeParameters_set_linear_success_probability(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, bool val); /** - * Creates a copy of the NodeId + * Creates a copy of the ProbabilisticScoringFeeParameters */ -struct LDKNodeId NodeId_clone(const struct LDKNodeId *NONNULL_PTR orig); +struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_clone(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR orig); /** - * Checks if two NodeIds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a "default" ProbabilisticScoringFeeParameters. See struct and individual field documentaiton for details on which values are used. */ -bool NodeId_eq(const struct LDKNodeId *NONNULL_PTR a, const struct LDKNodeId *NONNULL_PTR b); +MUST_USE_RES struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_default(void); /** - * Create a new NodeId from a public key + * Marks the node with the given `node_id` as banned, + * i.e it will be avoided during path finding. */ -MUST_USE_RES struct LDKNodeId NodeId_from_pubkey(struct LDKPublicKey pubkey); +void ProbabilisticScoringFeeParameters_add_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * Create a new NodeId from a slice of bytes + * Marks all nodes in the given list as banned, i.e., + * they will be avoided during path finding. */ -MUST_USE_RES struct LDKCResult_NodeIdDecodeErrorZ NodeId_from_slice(struct LDKu8slice bytes); +void ProbabilisticScoringFeeParameters_add_banned_from_list(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, struct LDKCVec_NodeIdZ node_ids); /** - * Get the public key slice from this NodeId + * Removes the node with the given `node_id` from the list of nodes to avoid. */ -MUST_USE_RES struct LDKu8slice NodeId_as_slice(const struct LDKNodeId *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_remove_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * Get the public key as an array from this NodeId + * Sets a manual penalty for the given node. */ -MUST_USE_RES const uint8_t (*NodeId_as_array(const struct LDKNodeId *NONNULL_PTR this_arg))[33]; +void ProbabilisticScoringFeeParameters_set_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id, uint64_t penalty); /** - * Get the public key from this NodeId + * Removes the node with the given `node_id` from the list of manual penalties. */ -MUST_USE_RES struct LDKCResult_PublicKeySecp256k1ErrorZ NodeId_as_pubkey(const struct LDKNodeId *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_remove_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * Get the string representation of a NodeId object + * Clears the list of manual penalties that are applied during path finding. */ -struct LDKStr NodeId_to_str(const struct LDKNodeId *NONNULL_PTR o); +void ProbabilisticScoringFeeParameters_clear_manual_penalties(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the NodeId. + * Frees any resources used by the ProbabilisticScoringDecayParameters, if is_owned is set and inner is non-NULL. */ -uint64_t NodeId_hash(const struct LDKNodeId *NONNULL_PTR o); +void ProbabilisticScoringDecayParameters_free(struct LDKProbabilisticScoringDecayParameters this_obj); /** - * Serialize the NodeId object into a byte array which can be read by NodeId_read + * If we aren't learning any new datapoints for a channel, the historical liquidity bounds + * tracking can simply live on with increasingly stale data. Instead, when a channel has not + * seen a liquidity estimate update for this amount of time, the historical datapoints are + * decayed by half. + * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] + * + * Note that after 16 or more half lives all historical data will be completely gone. + * + * Default value: 14 days + * + * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities */ -struct LDKCVec_u8Z NodeId_write(const struct LDKNodeId *NONNULL_PTR obj); +uint64_t ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); /** - * Read a NodeId from a byte array, created by NodeId_write + * If we aren't learning any new datapoints for a channel, the historical liquidity bounds + * tracking can simply live on with increasingly stale data. Instead, when a channel has not + * seen a liquidity estimate update for this amount of time, the historical datapoints are + * decayed by half. + * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] + * + * Note that after 16 or more half lives all historical data will be completely gone. + * + * Default value: 14 days + * + * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities */ -struct LDKCResult_NodeIdDecodeErrorZ NodeId_read(struct LDKu8slice ser); +void ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. + * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, + * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on + * the available liquidity is halved and the upper-bound moves half-way to the channel's total + * capacity. + * + * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, + * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] + * struct documentation for more info on the way the liquidity bounds are used. + * + * For example, if the channel's capacity is 1 million sats, and the current upper and lower + * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper + * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. + * + * Default value: 30 minutes + * + * # Note + * + * When not built with the `std` feature, time will never elapse. Therefore, the channel + * liquidity knowledge will never decay except when the bounds cross. */ -void NetworkGraph_free(struct LDKNetworkGraph this_obj); +uint64_t ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL. + * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, + * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on + * the available liquidity is halved and the upper-bound moves half-way to the channel's total + * capacity. + * + * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, + * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] + * struct documentation for more info on the way the liquidity bounds are used. + * + * For example, if the channel's capacity is 1 million sats, and the current upper and lower + * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper + * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. + * + * Default value: 30 minutes + * + * # Note + * + * When not built with the `std` feature, time will never elapse. Therefore, the channel + * liquidity knowledge will never decay except when the bounds cross. */ -void ReadOnlyNetworkGraph_free(struct LDKReadOnlyNetworkGraph this_obj); +void ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the NetworkUpdate + * Constructs a new ProbabilisticScoringDecayParameters given each field */ -void NetworkUpdate_free(struct LDKNetworkUpdate this_ptr); +MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_new(uint64_t historical_no_updates_half_life_arg, uint64_t liquidity_offset_half_life_arg); /** - * Creates a copy of the NetworkUpdate + * Creates a copy of the ProbabilisticScoringDecayParameters */ -struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNULL_PTR orig); +struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_clone(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR orig); /** - * Utility method to constructs a new ChannelFailure-variant NetworkUpdate + * Creates a "default" ProbabilisticScoringDecayParameters. See struct and individual field documentaiton for details on which values are used. */ -struct LDKNetworkUpdate NetworkUpdate_channel_failure(uint64_t short_channel_id, bool is_permanent); +MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_default(void); /** - * Utility method to constructs a new NodeFailure-variant NetworkUpdate + * Creates a new scorer using the given scoring parameters for sending payments from a node + * through a network graph. */ -struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); +MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringDecayParameters decay_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); /** - * Checks if two NetworkUpdates contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Dump the contents of this scorer into the configured logger. + * + * Note that this writes roughly one line per channel for which we have a liquidity estimate, + * which may be a substantial amount of log output. */ -bool NetworkUpdate_eq(const struct LDKNetworkUpdate *NONNULL_PTR a, const struct LDKNetworkUpdate *NONNULL_PTR b); +void ProbabilisticScorer_debug_log_liquidity_stats(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read + * Query the estimated minimum and maximum liquidity available for sending a payment over the + * channel with `scid` towards the given `target` node. */ -struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj); +MUST_USE_RES struct LDKCOption_C2Tuple_u64u64ZZ ProbabilisticScorer_estimated_channel_liquidity_range(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); /** - * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write + * Query the historical estimated minimum and maximum liquidity available for sending a + * payment over the channel with `scid` towards the given `target` node. + * + * Returns two sets of 32 buckets. The first set describes the lower-bound liquidity history, + * the second set describes the upper-bound liquidity history. Each bucket describes the + * relative frequency at which we've seen a liquidity bound in the bucket's range relative to + * the channel's total capacity, on an arbitrary scale. Because the values are slowly decayed, + * more recent data points are weighted more heavily than older datapoints. + * + * Note that the range of each bucket varies by its location to provide more granular results + * at the edges of a channel's capacity, where it is more likely to sit. + * + * When scoring, the estimated probability that an upper-/lower-bound lies in a given bucket + * is calculated by dividing that bucket's value with the total value of all buckets. + * + * For example, using a lower bucket count for illustrative purposes, a value of + * `[0, 0, 0, ..., 0, 32]` indicates that we believe the probability of a bound being very + * close to the channel's capacity to be 100%, and have never (recently) seen it in any other + * bucket. A value of `[31, 0, 0, ..., 0, 0, 32]` indicates we've seen the bound being both + * in the top and bottom bucket, and roughly with similar (recent) frequency. + * + * Because the datapoints are decayed slowly over time, values will eventually return to + * `Some(([0; 32], [0; 32]))` or `None` if no data remains for a channel. + * + * In order to fetch a single success probability from the buckets provided here, as used in + * the scoring model, see [`Self::historical_estimated_payment_success_probability`]. */ -struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); /** - * Frees any resources used by the P2PGossipSync, if is_owned is set and inner is non-NULL. + * Query the probability of payment success sending the given `amount_msat` over the channel + * with `scid` towards the given `target` node, based on the historical estimated liquidity + * bounds. + * + * Returns `None` if: + * - the given channel is not in the network graph, the provided `target` is not a party to + * the channel, or we don't have forwarding parameters for either direction in the channel. + * - `allow_fallback_estimation` is *not* set and there is no (or insufficient) historical + * data for the given channel. + * + * These are the same bounds as returned by + * [`Self::historical_estimated_channel_liquidity_probabilities`] (but not those returned by + * [`Self::estimated_channel_liquidity_range`]). */ -void P2PGossipSync_free(struct LDKP2PGossipSync this_obj); +MUST_USE_RES struct LDKCOption_f64Z ProbabilisticScorer_historical_estimated_payment_success_probability(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target, uint64_t amount_msat, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR params, bool allow_fallback_estimation); /** - * Creates a new tracker of the actual state of the network of channels and nodes, - * assuming an existing [`NetworkGraph`]. - * UTXO lookup is used to make sure announced channels exist on-chain, channel data is - * correct, and the announcement is signed with channel owners' keys. + * Query the probability of payment success sending the given `amount_msat` over the channel + * with `scid` towards the given `target` node, based on the live estimated liquidity bounds. + * + * This will return `Some` for any channel which is present in the [`NetworkGraph`], including + * if we have no bound information beside the channel's capacity. */ -MUST_USE_RES struct LDKP2PGossipSync P2PGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCOption_UtxoLookupZ utxo_lookup, struct LDKLogger logger); +MUST_USE_RES struct LDKCOption_f64Z ProbabilisticScorer_live_estimated_payment_success_probability(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target, uint64_t amount_msat, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR params); /** - * Adds a provider used to check new announcements. Does not affect - * existing announcements unless they are updated. - * Add, update or remove the provider would replace the current one. + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is */ -void P2PGossipSync_add_utxo_lookup(const struct LDKP2PGossipSync *NONNULL_PTR this_arg, struct LDKCOption_UtxoLookupZ utxo_lookup); +struct LDKScoreLookUp ProbabilisticScorer_as_ScoreLookUp(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * Handles any network updates originating from [`Event`]s. - * - * [`Event`]: crate::events::Event + * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is */ -void NetworkGraph_handle_network_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNetworkUpdate *NONNULL_PTR network_update); +struct LDKScoreUpdate ProbabilisticScorer_as_ScoreUpdate(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * Gets the chain hash for this network graph. + * Constructs a new Score which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is */ -MUST_USE_RES struct LDKThirtyTwoBytes NetworkGraph_get_chain_hash(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * Verifies the signature of a [`NodeAnnouncement`]. - * - * Returns an error if it is invalid. + * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read */ -struct LDKCResult_NoneLightningErrorZ verify_node_announcement(const struct LDKNodeAnnouncement *NONNULL_PTR msg); +struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj); /** - * Verifies all signatures included in a [`ChannelAnnouncement`]. - * - * Returns an error if one of the signatures is invalid. + * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write */ -struct LDKCResult_NoneLightningErrorZ verify_channel_announcement(const struct LDKChannelAnnouncement *NONNULL_PTR msg); +struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringDecayParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c); /** - * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is + * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -struct LDKRoutingMessageHandler P2PGossipSync_as_RoutingMessageHandler(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); +void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * The outpoint which is spendable. */ -struct LDKMessageSendEventsProvider P2PGossipSync_as_MessageSendEventsProvider(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); +struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL. + * The outpoint which is spendable. */ -void ChannelUpdateInfo_free(struct LDKChannelUpdateInfo this_obj); +void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * The minimum value, which must be relayed to the next hop via the channel + * Per commitment point to derive the delayed payment key by key holder. */ -uint64_t ChannelUpdateInfo_get_htlc_minimum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * The minimum value, which must be relayed to the next hop via the channel + * Per commitment point to derive the delayed payment key by key holder. */ -void ChannelUpdateInfo_set_htlc_minimum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); +void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The maximum value which may be relayed to the next hop via the channel. + * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in + * the witness_script. */ -uint64_t ChannelUpdateInfo_get_htlc_maximum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * The maximum value which may be relayed to the next hop via the channel. + * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in + * the witness_script. */ -void ChannelUpdateInfo_set_htlc_maximum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); +void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); /** - * Fees charged when the channel is used for routing + * The output which is referenced by the given outpoint. */ -struct LDKRoutingFees ChannelUpdateInfo_get_fees(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKTxOut DelayedPaymentOutputDescriptor_get_output(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Fees charged when the channel is used for routing + * The output which is referenced by the given outpoint. */ -void ChannelUpdateInfo_set_fees(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * When the last update to the channel direction was issued. - * Value is opaque, as set in the announcement. + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -uint32_t ChannelUpdateInfo_get_last_update(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKRevocationKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * When the last update to the channel direction was issued. - * Value is opaque, as set in the announcement. + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -void ChannelUpdateInfo_set_last_update(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint32_t val); +void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKRevocationKey val); /** - * The difference in CLTV values that you must have when routing through this channel. + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -uint16_t ChannelUpdateInfo_get_cltv_expiry_delta(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * The difference in CLTV values that you must have when routing through this channel. + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -void ChannelUpdateInfo_set_cltv_expiry_delta(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint16_t val); +void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Whether the channel can be currently used for payments (in this one direction). + * The value of the channel which this output originated from, possibly indirectly. */ -bool ChannelUpdateInfo_get_enabled(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Whether the channel can be currently used for payments (in this one direction). + * The value of the channel which this output originated from, possibly indirectly. */ -void ChannelUpdateInfo_set_enabled(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, bool val); +void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * Most recent update for the channel received from the network - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * The channel public keys and other parameters needed to generate a spending transaction or + * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. + * + * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKChannelUpdate ChannelUpdateInfo_get_last_update_message(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKChannelTransactionParameters DelayedPaymentOutputDescriptor_get_channel_transaction_parameters(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Most recent update for the channel received from the network - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * The channel public keys and other parameters needed to generate a spending transaction or + * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. + * + * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelUpdateInfo_set_last_update_message(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); +void DelayedPaymentOutputDescriptor_set_channel_transaction_parameters(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); /** - * Constructs a new ChannelUpdateInfo given each field + * Constructs a new DelayedPaymentOutputDescriptor given each field * - * Note that last_update_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -MUST_USE_RES struct LDKChannelUpdateInfo ChannelUpdateInfo_new(uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, uint32_t last_update_arg, uint16_t cltv_expiry_delta_arg, bool enabled_arg, struct LDKChannelUpdate last_update_message_arg); - -/** - * Creates a copy of the ChannelUpdateInfo + * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKChannelUpdateInfo ChannelUpdateInfo_clone(const struct LDKChannelUpdateInfo *NONNULL_PTR orig); +MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKRevocationKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg, struct LDKChannelTransactionParameters channel_transaction_parameters_arg); /** - * Checks if two ChannelUpdateInfos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the DelayedPaymentOutputDescriptor */ -bool ChannelUpdateInfo_eq(const struct LDKChannelUpdateInfo *NONNULL_PTR a, const struct LDKChannelUpdateInfo *NONNULL_PTR b); +struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); /** - * Get the string representation of a ChannelUpdateInfo object + * Generates a non-cryptographic 64-bit hash of the DelayedPaymentOutputDescriptor. */ -struct LDKStr ChannelUpdateInfo_to_str(const struct LDKChannelUpdateInfo *NONNULL_PTR o); +uint64_t DelayedPaymentOutputDescriptor_hash(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR o); /** - * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read + * Checks if two DelayedPaymentOutputDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCVec_u8Z ChannelUpdateInfo_write(const struct LDKChannelUpdateInfo *NONNULL_PTR obj); +bool DelayedPaymentOutputDescriptor_eq(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR b); /** - * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write + * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read */ -struct LDKCResult_ChannelUpdateInfoDecodeErrorZ ChannelUpdateInfo_read(struct LDKu8slice ser); +struct LDKCVec_u8Z DelayedPaymentOutputDescriptor_write(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR obj); /** - * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. + * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write */ -void ChannelInfo_free(struct LDKChannelInfo this_obj); +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ DelayedPaymentOutputDescriptor_read(struct LDKu8slice ser); /** - * Protocol features of a channel communicated during its announcement + * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -struct LDKChannelFeatures ChannelInfo_get_features(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); /** - * Protocol features of a channel communicated during its announcement + * The outpoint which is spendable. */ -void ChannelInfo_set_features(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Source node of the first direction of a channel + * The outpoint which is spendable. */ -struct LDKNodeId ChannelInfo_get_node_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Source node of the first direction of a channel + * The output which is referenced by the given outpoint. */ -void ChannelInfo_set_node_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); +struct LDKTxOut StaticPaymentOutputDescriptor_get_output(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Source node of the second direction of a channel + * The output which is referenced by the given outpoint. */ -struct LDKNodeId ChannelInfo_get_node_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Source node of the second direction of a channel + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -void ChannelInfo_set_node_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); +const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * The channel capacity as seen on-chain, if chain lookup is available. + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The channel capacity as seen on-chain, if chain lookup is available. + * The value of the channel which this transactions spends. */ -void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Details about the first direction of a channel - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The value of the channel which this transactions spends. */ -struct LDKChannelUpdateInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * Details about the first direction of a channel + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); - -/** - * Details about the second direction of a channel + * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKChannelUpdateInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); - -/** - * Details about the second direction of a channel - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); +struct LDKChannelTransactionParameters StaticPaymentOutputDescriptor_get_channel_transaction_parameters(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * An initial announcement of the channel - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); - -/** - * An initial announcement of the channel - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); - -/** - * Creates a copy of the ChannelInfo - */ -struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); - -/** - * Checks if two ChannelInfos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ -bool ChannelInfo_eq(const struct LDKChannelInfo *NONNULL_PTR a, const struct LDKChannelInfo *NONNULL_PTR b); +void StaticPaymentOutputDescriptor_set_channel_transaction_parameters(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); /** - * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag. + * Constructs a new StaticPaymentOutputDescriptor given each field * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -MUST_USE_RES struct LDKChannelUpdateInfo ChannelInfo_get_directional_info(const struct LDKChannelInfo *NONNULL_PTR this_arg, uint8_t channel_flags); - -/** - * Get the string representation of a ChannelInfo object - */ -struct LDKStr ChannelInfo_to_str(const struct LDKChannelInfo *NONNULL_PTR o); - -/** - * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read - */ -struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); - -/** - * Read a ChannelInfo from a byte array, created by ChannelInfo_write + * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg, struct LDKChannelTransactionParameters channel_transaction_parameters_arg); /** - * Frees any resources used by the DirectedChannelInfo, if is_owned is set and inner is non-NULL. + * Creates a copy of the StaticPaymentOutputDescriptor */ -void DirectedChannelInfo_free(struct LDKDirectedChannelInfo this_obj); +struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); /** - * Creates a copy of the DirectedChannelInfo + * Generates a non-cryptographic 64-bit hash of the StaticPaymentOutputDescriptor. */ -struct LDKDirectedChannelInfo DirectedChannelInfo_clone(const struct LDKDirectedChannelInfo *NONNULL_PTR orig); +uint64_t StaticPaymentOutputDescriptor_hash(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR o); /** - * Returns information for the channel. + * Checks if two StaticPaymentOutputDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKChannelInfo DirectedChannelInfo_channel(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +bool StaticPaymentOutputDescriptor_eq(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR b); /** - * Returns the [`EffectiveCapacity`] of the channel in the direction. + * Returns the `witness_script` of the spendable output. * - * This is either the total capacity from the funding transaction, if known, or the - * `htlc_maximum_msat` for the direction as advertised by the gossip network, if known, - * otherwise. + * Note that this will only return `Some` for [`StaticPaymentOutputDescriptor`]s that + * originated from an anchor outputs channel, as they take the form of a P2WSH script. */ -MUST_USE_RES struct LDKEffectiveCapacity DirectedChannelInfo_effective_capacity(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ StaticPaymentOutputDescriptor_witness_script(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); /** - * Returns the `node_id` of the source hop. - * - * Refers to the `node_id` forwarding the payment to the next hop. + * The maximum length a well-formed witness spending one of these should have. + * Note: If you have the grind_signatures feature enabled, this will be at least 1 byte + * shorter. */ -MUST_USE_RES struct LDKNodeId DirectedChannelInfo_source(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t StaticPaymentOutputDescriptor_max_witness_length(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); /** - * Returns the `node_id` of the target hop. - * - * Refers to the `node_id` receiving the payment from the previous hop. + * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read */ -MUST_USE_RES struct LDKNodeId DirectedChannelInfo_target(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +struct LDKCVec_u8Z StaticPaymentOutputDescriptor_write(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR obj); /** - * Frees any resources used by the EffectiveCapacity + * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write */ -void EffectiveCapacity_free(struct LDKEffectiveCapacity this_ptr); +struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ StaticPaymentOutputDescriptor_read(struct LDKu8slice ser); /** - * Creates a copy of the EffectiveCapacity + * Frees any resources used by the SpendableOutputDescriptor */ -struct LDKEffectiveCapacity EffectiveCapacity_clone(const struct LDKEffectiveCapacity *NONNULL_PTR orig); +void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); /** - * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity + * Creates a copy of the SpendableOutputDescriptor */ -struct LDKEffectiveCapacity EffectiveCapacity_exact_liquidity(uint64_t liquidity_msat); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); /** - * Utility method to constructs a new AdvertisedMaxHTLC-variant EffectiveCapacity + * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor */ -struct LDKEffectiveCapacity EffectiveCapacity_advertised_max_htlc(uint64_t amount_msat); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_output(struct LDKOutPoint outpoint, struct LDKTxOut output, struct LDKThirtyTwoBytes channel_keys_id); /** - * Utility method to constructs a new Total-variant EffectiveCapacity + * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor */ -struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat, uint64_t htlc_maximum_msat); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_output(struct LDKDelayedPaymentOutputDescriptor a); /** - * Utility method to constructs a new Infinite-variant EffectiveCapacity + * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor */ -struct LDKEffectiveCapacity EffectiveCapacity_infinite(void); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a); /** - * Utility method to constructs a new HintMaxHTLC-variant EffectiveCapacity + * Generates a non-cryptographic 64-bit hash of the SpendableOutputDescriptor. */ -struct LDKEffectiveCapacity EffectiveCapacity_hint_max_htlc(uint64_t amount_msat); +uint64_t SpendableOutputDescriptor_hash(const struct LDKSpendableOutputDescriptor *NONNULL_PTR o); /** - * Utility method to constructs a new Unknown-variant EffectiveCapacity + * Checks if two SpendableOutputDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKEffectiveCapacity EffectiveCapacity_unknown(void); +bool SpendableOutputDescriptor_eq(const struct LDKSpendableOutputDescriptor *NONNULL_PTR a, const struct LDKSpendableOutputDescriptor *NONNULL_PTR b); /** - * Returns the effective capacity denominated in millisatoshi. + * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read */ -MUST_USE_RES uint64_t EffectiveCapacity_as_msat(const struct LDKEffectiveCapacity *NONNULL_PTR this_arg); +struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); /** - * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read + * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write */ -struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); /** - * Read a RoutingFees from a byte array, created by RoutingFees_write + * Creates an unsigned [`Psbt`] which spends the given descriptors to + * the given outputs, plus an output to the given change destination (if sufficient + * change value remains). The PSBT will have a feerate, at least, of the given value. + * + * The `locktime` argument is used to set the transaction's locktime. If `None`, the + * transaction will have a locktime of 0. It it recommended to set this to the current block + * height to avoid fee sniping, unless you have some specific reason to use a different + * locktime. + * + * Returns the PSBT and expected max transaction weight. + * + * Returns `Err(())` if the output value is greater than the input value minus required fee, + * if a descriptor was duplicated, or if an output descriptor `script_pubkey` + * does not match the one we can spend. + * + * We do not enforce that outputs meet the dust limit or that any output scripts are standard. */ -struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_C2Tuple_CVec_u8Zu64ZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_u32Z locktime); /** - * Frees any resources used by the NodeAnnouncementDetails, if is_owned is set and inner is non-NULL. + * Returns the outpoint of the spendable output. */ -void NodeAnnouncementDetails_free(struct LDKNodeAnnouncementDetails this_obj); +MUST_USE_RES struct LDKOutPoint SpendableOutputDescriptor_spendable_outpoint(const struct LDKSpendableOutputDescriptor *NONNULL_PTR this_arg); /** - * Protocol features the node announced support for + * Frees any resources used by the ChannelDerivationParameters, if is_owned is set and inner is non-NULL. */ -struct LDKNodeFeatures NodeAnnouncementDetails_get_features(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); +void ChannelDerivationParameters_free(struct LDKChannelDerivationParameters this_obj); /** - * Protocol features the node announced support for + * The value in satoshis of the channel we're attempting to spend the anchor output of. */ -void NodeAnnouncementDetails_set_features(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +uint64_t ChannelDerivationParameters_get_value_satoshis(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); /** - * When the last known update to the node state was issued. - * Value is opaque, as set in the announcement. + * The value in satoshis of the channel we're attempting to spend the anchor output of. */ -uint32_t NodeAnnouncementDetails_get_last_update(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); +void ChannelDerivationParameters_set_value_satoshis(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * When the last known update to the node state was issued. - * Value is opaque, as set in the announcement. + * The unique identifier to re-derive the signer for the associated channel. */ -void NodeAnnouncementDetails_set_last_update(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, uint32_t val); +const uint8_t (*ChannelDerivationParameters_get_keys_id(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr))[32]; /** - * Color assigned to the node + * The unique identifier to re-derive the signer for the associated channel. */ -const uint8_t (*NodeAnnouncementDetails_get_rgb(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr))[3]; +void ChannelDerivationParameters_set_keys_id(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Color assigned to the node + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. */ -void NodeAnnouncementDetails_set_rgb(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKThreeBytes val); +struct LDKChannelTransactionParameters ChannelDerivationParameters_get_transaction_parameters(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); /** - * Moniker assigned to the node. - * May be invalid or malicious (eg control chars), - * should not be exposed to the user. + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. */ -struct LDKNodeAlias NodeAnnouncementDetails_get_alias(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); +void ChannelDerivationParameters_set_transaction_parameters(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); /** - * Moniker assigned to the node. - * May be invalid or malicious (eg control chars), - * should not be exposed to the user. + * Constructs a new ChannelDerivationParameters given each field */ -void NodeAnnouncementDetails_set_alias(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKNodeAlias val); +MUST_USE_RES struct LDKChannelDerivationParameters ChannelDerivationParameters_new(uint64_t value_satoshis_arg, struct LDKThirtyTwoBytes keys_id_arg, struct LDKChannelTransactionParameters transaction_parameters_arg); /** - * Internet-level addresses via which one can connect to the node - * - * Returns a copy of the field. + * Creates a copy of the ChannelDerivationParameters */ -struct LDKCVec_SocketAddressZ NodeAnnouncementDetails_get_addresses(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); +struct LDKChannelDerivationParameters ChannelDerivationParameters_clone(const struct LDKChannelDerivationParameters *NONNULL_PTR orig); /** - * Internet-level addresses via which one can connect to the node + * Checks if two ChannelDerivationParameterss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void NodeAnnouncementDetails_set_addresses(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKCVec_SocketAddressZ val); +bool ChannelDerivationParameters_eq(const struct LDKChannelDerivationParameters *NONNULL_PTR a, const struct LDKChannelDerivationParameters *NONNULL_PTR b); /** - * Constructs a new NodeAnnouncementDetails given each field + * Serialize the ChannelDerivationParameters object into a byte array which can be read by ChannelDerivationParameters_read */ -MUST_USE_RES struct LDKNodeAnnouncementDetails NodeAnnouncementDetails_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKNodeAlias alias_arg, struct LDKCVec_SocketAddressZ addresses_arg); +struct LDKCVec_u8Z ChannelDerivationParameters_write(const struct LDKChannelDerivationParameters *NONNULL_PTR obj); /** - * Creates a copy of the NodeAnnouncementDetails + * Read a ChannelDerivationParameters from a byte array, created by ChannelDerivationParameters_write */ -struct LDKNodeAnnouncementDetails NodeAnnouncementDetails_clone(const struct LDKNodeAnnouncementDetails *NONNULL_PTR orig); +struct LDKCResult_ChannelDerivationParametersDecodeErrorZ ChannelDerivationParameters_read(struct LDKu8slice ser); /** - * Checks if two NodeAnnouncementDetailss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Frees any resources used by the HTLCDescriptor, if is_owned is set and inner is non-NULL. */ -bool NodeAnnouncementDetails_eq(const struct LDKNodeAnnouncementDetails *NONNULL_PTR a, const struct LDKNodeAnnouncementDetails *NONNULL_PTR b); +void HTLCDescriptor_free(struct LDKHTLCDescriptor this_obj); /** - * Frees any resources used by the NodeAnnouncementInfo + * The parameters required to derive the signer for the HTLC input. */ -void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_ptr); +struct LDKChannelDerivationParameters HTLCDescriptor_get_channel_derivation_parameters(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Creates a copy of the NodeAnnouncementInfo + * The parameters required to derive the signer for the HTLC input. */ -struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); +void HTLCDescriptor_set_channel_derivation_parameters(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); /** - * Utility method to constructs a new Relayed-variant NodeAnnouncementInfo + * The txid of the commitment transaction in which the HTLC output lives. */ -struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_relayed(struct LDKNodeAnnouncement a); +const uint8_t (*HTLCDescriptor_get_commitment_txid(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new Local-variant NodeAnnouncementInfo + * The txid of the commitment transaction in which the HTLC output lives. */ -struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_local(struct LDKNodeAnnouncementDetails a); +void HTLCDescriptor_set_commitment_txid(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Checks if two NodeAnnouncementInfos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * The number of the commitment transaction in which the HTLC output lives. */ -bool NodeAnnouncementInfo_eq(const struct LDKNodeAnnouncementInfo *NONNULL_PTR a, const struct LDKNodeAnnouncementInfo *NONNULL_PTR b); +uint64_t HTLCDescriptor_get_per_commitment_number(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Protocol features the node announced support for + * The number of the commitment transaction in which the HTLC output lives. */ -MUST_USE_RES struct LDKNodeFeatures NodeAnnouncementInfo_features(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); +void HTLCDescriptor_set_per_commitment_number(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * When the last known update to the node state was issued. + * The key tweak corresponding to the number of the commitment transaction in which the HTLC + * output lives. This tweak is applied to all the basepoints for both parties in the channel to + * arrive at unique keys per commitment. * - * Value may or may not be a timestamp, depending on the policy of the origin node. + * See for more info. */ -MUST_USE_RES uint32_t NodeAnnouncementInfo_last_update(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); +struct LDKPublicKey HTLCDescriptor_get_per_commitment_point(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Color assigned to the node + * The key tweak corresponding to the number of the commitment transaction in which the HTLC + * output lives. This tweak is applied to all the basepoints for both parties in the channel to + * arrive at unique keys per commitment. + * + * See for more info. */ -MUST_USE_RES struct LDKThreeBytes NodeAnnouncementInfo_rgb(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); +void HTLCDescriptor_set_per_commitment_point(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Moniker assigned to the node. - * - * May be invalid or malicious (eg control chars), should not be exposed to the user. + * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs + * originating from a channel supporting anchor outputs, otherwise it is the channel's + * negotiated feerate at the time the commitment transaction was built. */ -MUST_USE_RES struct LDKNodeAlias NodeAnnouncementInfo_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); +uint32_t HTLCDescriptor_get_feerate_per_kw(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Internet-level addresses via which one can connect to the node + * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs + * originating from a channel supporting anchor outputs, otherwise it is the channel's + * negotiated feerate at the time the commitment transaction was built. */ -MUST_USE_RES struct LDKCVec_SocketAddressZ NodeAnnouncementInfo_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); +void HTLCDescriptor_set_feerate_per_kw(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint32_t val); /** - * An initial announcement of the node - * - * Not stored if contains excess data to prevent DoS. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The details of the HTLC as it appears in the commitment transaction. */ -MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncementInfo_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); +struct LDKHTLCOutputInCommitment HTLCDescriptor_get_htlc(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read + * The details of the HTLC as it appears in the commitment transaction. */ -struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *NONNULL_PTR obj); +void HTLCDescriptor_set_htlc(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKHTLCOutputInCommitment val); /** - * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write + * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be + * taken. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); +struct LDKCOption_ThirtyTwoBytesZ HTLCDescriptor_get_preimage(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Frees any resources used by the NodeAlias, if is_owned is set and inner is non-NULL. + * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be + * taken. */ -void NodeAlias_free(struct LDKNodeAlias this_obj); - -const uint8_t (*NodeAlias_get_a(const struct LDKNodeAlias *NONNULL_PTR this_ptr))[32]; +void HTLCDescriptor_set_preimage(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); -void NodeAlias_set_a(struct LDKNodeAlias *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * The counterparty's signature required to spend the HTLC output. + */ +struct LDKECDSASignature HTLCDescriptor_get_counterparty_sig(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Constructs a new NodeAlias given each field + * The counterparty's signature required to spend the HTLC output. */ -MUST_USE_RES struct LDKNodeAlias NodeAlias_new(struct LDKThirtyTwoBytes a_arg); +void HTLCDescriptor_set_counterparty_sig(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * Creates a copy of the NodeAlias + * Constructs a new HTLCDescriptor given each field */ -struct LDKNodeAlias NodeAlias_clone(const struct LDKNodeAlias *NONNULL_PTR orig); +MUST_USE_RES struct LDKHTLCDescriptor HTLCDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKThirtyTwoBytes commitment_txid_arg, uint64_t per_commitment_number_arg, struct LDKPublicKey per_commitment_point_arg, uint32_t feerate_per_kw_arg, struct LDKHTLCOutputInCommitment htlc_arg, struct LDKCOption_ThirtyTwoBytesZ preimage_arg, struct LDKECDSASignature counterparty_sig_arg); /** - * Generates a non-cryptographic 64-bit hash of the NodeAlias. + * Creates a copy of the HTLCDescriptor */ -uint64_t NodeAlias_hash(const struct LDKNodeAlias *NONNULL_PTR o); +struct LDKHTLCDescriptor HTLCDescriptor_clone(const struct LDKHTLCDescriptor *NONNULL_PTR orig); /** - * Checks if two NodeAliass contain equal inner contents. + * Checks if two HTLCDescriptors contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool NodeAlias_eq(const struct LDKNodeAlias *NONNULL_PTR a, const struct LDKNodeAlias *NONNULL_PTR b); +bool HTLCDescriptor_eq(const struct LDKHTLCDescriptor *NONNULL_PTR a, const struct LDKHTLCDescriptor *NONNULL_PTR b); /** - * Get the string representation of a NodeAlias object + * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read */ -struct LDKStr NodeAlias_to_str(const struct LDKNodeAlias *NONNULL_PTR o); +struct LDKCVec_u8Z HTLCDescriptor_write(const struct LDKHTLCDescriptor *NONNULL_PTR obj); /** - * Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read + * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write */ -struct LDKCVec_u8Z NodeAlias_write(const struct LDKNodeAlias *NONNULL_PTR obj); +struct LDKCResult_HTLCDescriptorDecodeErrorZ HTLCDescriptor_read(struct LDKu8slice ser); /** - * Read a NodeAlias from a byte array, created by NodeAlias_write + * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint + * being spent by the HTLC input in the HTLC transaction. */ -struct LDKCResult_NodeAliasDecodeErrorZ NodeAlias_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKOutPoint HTLCDescriptor_outpoint(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. + * Returns the UTXO to be spent by the HTLC input, which can be obtained via + * [`Self::unsigned_tx_input`]. */ -void NodeInfo_free(struct LDKNodeInfo this_obj); +MUST_USE_RES struct LDKTxOut HTLCDescriptor_previous_utxo(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * All valid channels a node has announced - * - * Returns a copy of the field. + * Returns the unsigned transaction input spending the HTLC output in the commitment + * transaction. */ -struct LDKCVec_u64Z NodeInfo_get_channels(const struct LDKNodeInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxIn HTLCDescriptor_unsigned_tx_input(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * All valid channels a node has announced + * Returns the delayed output created as a result of spending the HTLC output in the commitment + * transaction. */ -void NodeInfo_set_channels(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +MUST_USE_RES struct LDKTxOut HTLCDescriptor_tx_output(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * More information about a node from node_announcement. - * Optional because we store a Node entry after learning about it from - * a channel announcement, but before receiving a node announcement. - * - * Returns a copy of the field. + * Returns the witness script of the HTLC output in the commitment transaction. */ -struct LDKCOption_NodeAnnouncementInfoZ NodeInfo_get_announcement_info(const struct LDKNodeInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_u8Z HTLCDescriptor_witness_script(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * More information about a node from node_announcement. - * Optional because we store a Node entry after learning about it from - * a channel announcement, but before receiving a node announcement. + * Returns the fully signed witness required to spend the HTLC output in the commitment + * transaction. */ -void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCOption_NodeAnnouncementInfoZ val); +MUST_USE_RES struct LDKWitness HTLCDescriptor_tx_input_witness(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature, struct LDKu8slice witness_script); /** - * Creates a copy of the NodeInfo + * Derives the channel signer required to sign the HTLC input. */ -struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); +MUST_USE_RES struct LDKEcdsaChannelSigner HTLCDescriptor_derive_channel_signer(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); /** - * Checks if two NodeInfos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Calls the free function if one is set */ -bool NodeInfo_eq(const struct LDKNodeInfo *NONNULL_PTR a, const struct LDKNodeInfo *NONNULL_PTR b); +void ChannelSigner_free(struct LDKChannelSigner this_ptr); /** - * Returns whether the node has only announced Tor addresses. + * Creates a copy of the Recipient */ -MUST_USE_RES bool NodeInfo_is_tor_only(const struct LDKNodeInfo *NONNULL_PTR this_arg); +enum LDKRecipient Recipient_clone(const enum LDKRecipient *NONNULL_PTR orig); /** - * Get the string representation of a NodeInfo object + * Utility method to constructs a new Node-variant Recipient */ -struct LDKStr NodeInfo_to_str(const struct LDKNodeInfo *NONNULL_PTR o); +enum LDKRecipient Recipient_node(void); /** - * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read + * Utility method to constructs a new PhantomNode-variant Recipient */ -struct LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *NONNULL_PTR obj); +enum LDKRecipient Recipient_phantom_node(void); /** - * Read a NodeInfo from a byte array, created by NodeInfo_write + * Calls the free function if one is set */ -struct LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser); +void EntropySource_free(struct LDKEntropySource this_ptr); /** - * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read + * Calls the free function if one is set */ -struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR obj); +void NodeSigner_free(struct LDKNodeSigner this_ptr); /** - * Read a NetworkGraph from a byte array, created by NetworkGraph_write + * Calls the free function if one is set */ -struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser, struct LDKLogger arg); +void OutputSpender_free(struct LDKOutputSpender this_ptr); /** - * Get the string representation of a NetworkGraph object + * Calls the free function if one is set */ -struct LDKStr NetworkGraph_to_str(const struct LDKNetworkGraph *NONNULL_PTR o); +void SignerProvider_free(struct LDKSignerProvider this_ptr); /** - * Creates a new, empty, network graph. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(enum LDKNetwork network, struct LDKLogger logger); +void ChangeDestinationSource_free(struct LDKChangeDestinationSource this_ptr); /** - * Returns a read-only view of the network graph. + * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +void InMemorySigner_free(struct LDKInMemorySigner this_obj); /** - * The unix timestamp provided by the most recent rapid gossip sync. - * It will be set by the rapid sync process after every sync completion. + * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the + * holder's anchor output in a commitment transaction, if one is present. */ -MUST_USE_RES struct LDKCOption_u32Z NetworkGraph_get_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Update the unix timestamp provided by the most recent rapid gossip sync. - * This should be done automatically by the rapid sync process after every sync completion. + * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the + * holder's anchor output in a commitment transaction, if one is present. */ -void NetworkGraph_set_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint32_t last_rapid_gossip_sync_timestamp); +void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * For an already known node (from channel announcements), update its stored properties from a - * given node announcement. - * - * You probably don't want to call this directly, instead relying on a P2PGossipSync's - * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. + * Holder secret key for blinded revocation pubkey. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); +const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * For an already known node (from channel announcements), update its stored properties from a - * given node announcement without verifying the associated signatures. Because we aren't - * given the associated signatures here we cannot relay the node announcement to any of our - * peers. + * Holder secret key for blinded revocation pubkey. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); +void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Store or update channel info from a channel announcement. - * - * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s - * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. - * - * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify - * the corresponding UTXO exists on chain and is correctly-formatted. + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); +const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Store or update channel info from a channel announcement. - * - * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s - * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. - * - * This will skip verification of if the channel is actually on-chain. + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement_no_lookup(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg); +void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Store or update channel info from a channel announcement without verifying the associated - * signatures. Because we aren't given the associated signatures here we cannot relay the - * channel announcement to any of our peers. - * - * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify - * the corresponding UTXO exists on chain and is correctly-formatted. + * Holder secret key used in an HTLC transaction. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); +const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Update channel from partial announcement data received via rapid gossip sync - * - * `timestamp: u64`: Timestamp emulating the backdated original announcement receipt (by the - * rapid gossip sync server) - * - * All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields. + * Holder secret key used in an HTLC transaction. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_add_channel_from_partial_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, uint64_t timestamp, struct LDKChannelFeatures features, struct LDKPublicKey node_id_1, struct LDKPublicKey node_id_2); +void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Marks a channel in the graph as failed permanently. - * - * The channel and any node for which this was their last channel are removed from the graph. + * Holder HTLC secret key used in commitment transaction HTLC outputs. */ -void NetworkGraph_channel_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); +const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Marks a node in the graph as permanently failed, effectively removing it and its channels - * from local storage. + * Holder HTLC secret key used in commitment transaction HTLC outputs. */ -void NetworkGraph_node_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey node_id); +void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Removes information about channels that we haven't heard any updates about in some time. - * This can be used regularly to prune the network graph of channels that likely no longer - * exist. - * - * While there is no formal requirement that nodes regularly re-broadcast their channel - * updates every two weeks, the non-normative section of BOLT 7 currently suggests that - * pruning occur for updates which are at least two weeks old, which we implement here. - * - * Note that for users of the `lightning-background-processor` crate this method may be - * automatically called regularly for you. - * - * This method will also cause us to stop tracking removed nodes and channels if they have been - * in the map for a while so that these can be resynced from gossip in the future. - * - * This method is only available with the `std` feature. See - * [`NetworkGraph::remove_stale_channels_and_tracking_with_time`] for non-`std` use. + * Commitment seed. */ -void NetworkGraph_remove_stale_channels_and_tracking(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Removes information about channels that we haven't heard any updates about in some time. - * This can be used regularly to prune the network graph of channels that likely no longer - * exist. - * - * While there is no formal requirement that nodes regularly re-broadcast their channel - * updates every two weeks, the non-normative section of BOLT 7 currently suggests that - * pruning occur for updates which are at least two weeks old, which we implement here. - * - * This method will also cause us to stop tracking removed nodes and channels if they have been - * in the map for a while so that these can be resynced from gossip in the future. - * - *This function takes the current unix time as an argument. For users with the `std` feature - *enabled, [`NetworkGraph::remove_stale_channels_and_tracking`] may be preferable. + * Commitment seed. */ -void NetworkGraph_remove_stale_channels_and_tracking_with_time(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t current_time_unix); +void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * For an already known (from announcement) channel, update info about one of the directions - * of the channel. - * - * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s - * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. - * - * If not built with `std`, any updates with a timestamp more than two weeks in the past or - * materially in the future will be rejected. + * Creates a copy of the InMemorySigner */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); +struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); /** - * For an already known (from announcement) channel, update info about one of the directions - * of the channel without verifying the associated signatures. Because we aren't given the - * associated signatures here we cannot relay the channel update to any of our peers. - * - * If not built with `std`, any updates with a timestamp more than two weeks in the past or - * materially in the future will be rejected. + * Creates a new [`InMemorySigner`]. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); +MUST_USE_RES struct LDKInMemorySigner InMemorySigner_new(struct LDKSecretKey funding_key, struct LDKSecretKey revocation_base_key, struct LDKSecretKey payment_key, struct LDKSecretKey delayed_payment_base_key, struct LDKSecretKey htlc_base_key, struct LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id, struct LDKThirtyTwoBytes rand_bytes_unique_start); /** - * For an already known (from announcement) channel, verify the given [`ChannelUpdate`]. - * - * This checks whether the update currently is applicable by [`Self::update_channel`]. + * Returns the counterparty's pubkeys. * - * If not built with `std`, any updates with a timestamp more than two weeks in the past or - * materially in the future will be rejected. - */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_verify_channel_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); - -/** - * Returns information on a channel with the given id. + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); - -/** - * Returns the list of channels in the graph - */ -MUST_USE_RES struct LDKCVec_u64Z ReadOnlyNetworkGraph_list_channels(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Returns information on a node with the given id. + * Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable + * transactions, i.e., the amount of time that we have to wait to recover our funds if we + * broadcast a transaction. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ -MUST_USE_RES struct LDKNodeInfo ReadOnlyNetworkGraph_node(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +MUST_USE_RES struct LDKCOption_u16Z InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Returns the list of nodes in the graph + * Returns the `contest_delay` value specified by us and applied on transactions broadcastable + * by our counterparty, i.e., the amount of time that they have to wait to recover their funds + * if they broadcast a transaction. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ -MUST_USE_RES struct LDKCVec_NodeIdZ ReadOnlyNetworkGraph_list_nodes(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u16Z InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Get network addresses by node id. - * Returns None if the requested node is completely unknown, - * or if node announcement for the node was never received. + * Returns whether the holder is the initiator. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ -MUST_USE_RES struct LDKCOption_CVec_SocketAddressZZ ReadOnlyNetworkGraph_get_addresses(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey pubkey); +MUST_USE_RES struct LDKCOption_boolZ InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL. + * Funding outpoint + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void DefaultRouter_free(struct LDKDefaultRouter this_obj); +MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Creates a new router. + * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or + * building transactions. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKEntropySource entropy_source, struct LDKLockableScore scorer, struct LDKProbabilisticScoringFeeParameters score_params); +MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Constructs a new Router which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Router must be freed before this_arg is + * Returns the channel type features of the channel parameters. Should be helpful for + * determining a channel's category, i. e. legacy/anchors/taproot/etc. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKRouter DefaultRouter_as_Router(const struct LDKDefaultRouter *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelTypeFeatures InMemorySigner_channel_type_features(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Sign the single input of `spend_tx` at index `input_idx`, which spends the output described + * by `descriptor`, returning the witness stack for the input. + * + * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, + * is not spending the outpoint described by [`descriptor.outpoint`], + * or if an output descriptor `script_pubkey` does not match the one we can spend. + * + * [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint */ -void Router_free(struct LDKRouter this_ptr); +MUST_USE_RES struct LDKCResult_WitnessNoneZ InMemorySigner_sign_counterparty_payment_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR descriptor); /** - * Frees any resources used by the ScorerAccountingForInFlightHtlcs, if is_owned is set and inner is non-NULL. + * Sign the single input of `spend_tx` at index `input_idx` which spends the output + * described by `descriptor`, returning the witness stack for the input. + * + * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, + * is not spending the outpoint described by [`descriptor.outpoint`], does not have a + * sequence set to [`descriptor.to_self_delay`], or if an output descriptor + * `script_pubkey` does not match the one we can spend. + * + * [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint + * [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay */ -void ScorerAccountingForInFlightHtlcs_free(struct LDKScorerAccountingForInFlightHtlcs this_obj); +MUST_USE_RES struct LDKCResult_WitnessNoneZ InMemorySigner_sign_dynamic_p2wsh_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); /** - * Initialize a new `ScorerAccountingForInFlightHtlcs`. + * Constructs a new EntropySource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is */ -MUST_USE_RES struct LDKScorerAccountingForInFlightHtlcs ScorerAccountingForInFlightHtlcs_new(struct LDKScoreLookUp scorer, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs); +struct LDKEntropySource InMemorySigner_as_EntropySource(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * Constructs a new ChannelSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is */ -struct LDKScoreLookUp ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(const struct LDKScorerAccountingForInFlightHtlcs *NONNULL_PTR this_arg); +struct LDKChannelSigner InMemorySigner_as_ChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL. + * Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is */ -void InFlightHtlcs_free(struct LDKInFlightHtlcs this_obj); +struct LDKEcdsaChannelSigner InMemorySigner_as_EcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Creates a copy of the InFlightHtlcs + * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read */ -struct LDKInFlightHtlcs InFlightHtlcs_clone(const struct LDKInFlightHtlcs *NONNULL_PTR orig); +struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); /** - * Constructs an empty `InFlightHtlcs`. + * Read a InMemorySigner from a byte array, created by InMemorySigner_write */ -MUST_USE_RES struct LDKInFlightHtlcs InFlightHtlcs_new(void); +struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKEntropySource arg); /** - * Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`. + * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. */ -void InFlightHtlcs_process_path(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKPath *NONNULL_PTR path, struct LDKPublicKey payer_node_id); +void KeysManager_free(struct LDKKeysManager this_obj); /** - * Adds a known HTLC given the public key of the HTLC source, target, and short channel - * id. + * Constructs a [`KeysManager`] from a 32-byte seed. If the seed is in some way biased (e.g., + * your CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). + * `starting_time` isn't strictly required to actually be a time, but it must absolutely, + * without a doubt, be unique to this instance. ie if you start multiple times with the same + * `seed`, `starting_time` must be unique to each run. Thus, the easiest way to achieve this + * is to simply use the current time (with very high precision). + * + * The `seed` MUST be backed up safely prior to use so that the keys can be re-created, however, + * obviously, `starting_time` should be unique every time you reload the library - it is only + * used to generate new ephemeral key data (which will be stored by the individual channel if + * necessary). + * + * Note that the seed is required to recover certain on-chain funds independent of + * [`ChannelMonitor`] data, though a current copy of [`ChannelMonitor`] data is also required + * for any channel, and some on-chain during-closing funds. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor */ -void InFlightHtlcs_add_inflight_htlc(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid, uint64_t used_msat); +MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); /** - * Returns liquidity in msat given the public key of the HTLC source, target, and short channel - * id. + * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. */ -MUST_USE_RES struct LDKCOption_u64Z InFlightHtlcs_used_liquidity_msat(const struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid); +MUST_USE_RES struct LDKSecretKey KeysManager_get_node_secret_key(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read + * Derive an old [`EcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. */ -struct LDKCVec_u8Z InFlightHtlcs_write(const struct LDKInFlightHtlcs *NONNULL_PTR obj); +MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); /** - * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write + * Signs the given [`Psbt`] which spends the given [`SpendableOutputDescriptor`]s. + * The resulting inputs will be finalized and the PSBT will be ready for broadcast if there + * are no other inputs that need signing. + * + * Returns `Err(())` if the PSBT is missing a descriptor or if we fail to sign. + * + * May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used + * this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. */ -struct LDKCResult_InFlightHtlcsDecodeErrorZ InFlightHtlcs_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_CVec_u8ZNoneZ KeysManager_sign_spendable_outputs_psbt(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_u8Z psbt); /** - * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. + * Constructs a new EntropySource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is */ -void RouteHop_free(struct LDKRouteHop this_obj); +struct LDKEntropySource KeysManager_as_EntropySource(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * The node_id of the node at this hop. + * Constructs a new NodeSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is */ -struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKNodeSigner KeysManager_as_NodeSigner(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * The node_id of the node at this hop. + * Constructs a new OutputSpender which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is */ -void RouteHop_set_pubkey(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKOutputSpender KeysManager_as_OutputSpender(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * The node_announcement features of the node at this hop. For the last hop, these may be - * amended to match the features present in the invoice this node generated. + * Constructs a new SignerProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is */ -struct LDKNodeFeatures RouteHop_get_node_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKSignerProvider KeysManager_as_SignerProvider(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * The node_announcement features of the node at this hop. For the last hop, these may be - * amended to match the features present in the invoice this node generated. + * Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. */ -void RouteHop_set_node_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +void PhantomKeysManager_free(struct LDKPhantomKeysManager this_obj); /** - * The channel that should be used from the previous hop to reach this node. + * Constructs a new EntropySource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is */ -uint64_t RouteHop_get_short_channel_id(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKEntropySource PhantomKeysManager_as_EntropySource(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * The channel that should be used from the previous hop to reach this node. + * Constructs a new NodeSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is */ -void RouteHop_set_short_channel_id(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); +struct LDKNodeSigner PhantomKeysManager_as_NodeSigner(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * The channel_announcement features of the channel that should be used from the previous hop - * to reach this node. + * Constructs a new OutputSpender which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is */ -struct LDKChannelFeatures RouteHop_get_channel_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKOutputSpender PhantomKeysManager_as_OutputSpender(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * The channel_announcement features of the channel that should be used from the previous hop - * to reach this node. + * Constructs a new SignerProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is */ -void RouteHop_set_channel_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +struct LDKSignerProvider PhantomKeysManager_as_SignerProvider(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * The fee taken on this hop (for paying for the use of the *next* channel in the path). - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPaymentPath`], this is the fee paid for use of the entire - * blinded path - * * otherwise, this is the full value of this [`Path`]'s part of the payment + * Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed` + * that is shared across all nodes that intend to participate in [phantom node payments] + * together. + * + * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and + * `starting_time_nanos`. + * + * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the + * same across restarts, or else inbound payments may fail. + * + * [phantom node payments]: PhantomKeysManager */ -uint64_t RouteHop_get_fee_msat(const struct LDKRouteHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPhantomKeysManager PhantomKeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos, const uint8_t (*cross_node_seed)[32]); /** - * The fee taken on this hop (for paying for the use of the *next* channel in the path). - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPaymentPath`], this is the fee paid for use of the entire - * blinded path - * * otherwise, this is the full value of this [`Path`]'s part of the payment + * See [`KeysManager::derive_channel_keys`] for documentation on this method. */ -void RouteHop_set_fee_msat(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKInMemorySigner PhantomKeysManager_derive_channel_keys(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); /** - * The CLTV delta added for this hop. - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded - * path - * * otherwise, this is the CLTV delta expected at the destination + * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. */ -uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * The CLTV delta added for this hop. - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded - * path - * * otherwise, this is the CLTV delta expected at the destination + * Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the + * last-hop onion data, etc. */ -void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_phantom_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * Indicates whether this hop is possibly announced in the public network graph. - * - * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we - * either know for sure it's announced in the public graph, or if any public channels exist - * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe - * the channel to be unannounced. - * - * Will be `true` for objects serialized with LDK version 0.0.116 and before. + * Frees any resources used by the RandomBytes, if is_owned is set and inner is non-NULL. */ -bool RouteHop_get_maybe_announced_channel(const struct LDKRouteHop *NONNULL_PTR this_ptr); +void RandomBytes_free(struct LDKRandomBytes this_obj); /** - * Indicates whether this hop is possibly announced in the public network graph. - * - * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we - * either know for sure it's announced in the public graph, or if any public channels exist - * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe - * the channel to be unannounced. - * - * Will be `true` for objects serialized with LDK version 0.0.116 and before. + * Creates a new instance using the given seed. */ -void RouteHop_set_maybe_announced_channel(struct LDKRouteHop *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKRandomBytes RandomBytes_new(struct LDKThirtyTwoBytes seed); /** - * Constructs a new RouteHop given each field + * Constructs a new EntropySource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is */ -MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg, bool maybe_announced_channel_arg); +struct LDKEntropySource RandomBytes_as_EntropySource(const struct LDKRandomBytes *NONNULL_PTR this_arg); /** - * Creates a copy of the RouteHop + * Creates a copy of a EcdsaChannelSigner */ -struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); +struct LDKEcdsaChannelSigner EcdsaChannelSigner_clone(const struct LDKEcdsaChannelSigner *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the RouteHop. + * Calls the free function if one is set */ -uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o); +void EcdsaChannelSigner_free(struct LDKEcdsaChannelSigner this_ptr); /** - * Checks if two RouteHops contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Calls the free function if one is set */ -bool RouteHop_eq(const struct LDKRouteHop *NONNULL_PTR a, const struct LDKRouteHop *NONNULL_PTR b); +void AsyncPaymentsMessageHandler_free(struct LDKAsyncPaymentsMessageHandler this_ptr); /** - * Serialize the RouteHop object into a byte array which can be read by RouteHop_read + * Frees any resources used by the AsyncPaymentsMessage */ -struct LDKCVec_u8Z RouteHop_write(const struct LDKRouteHop *NONNULL_PTR obj); +void AsyncPaymentsMessage_free(struct LDKAsyncPaymentsMessage this_ptr); /** - * Read a RouteHop from a byte array, created by RouteHop_write + * Creates a copy of the AsyncPaymentsMessage */ -struct LDKCResult_RouteHopDecodeErrorZ RouteHop_read(struct LDKu8slice ser); +struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_clone(const struct LDKAsyncPaymentsMessage *NONNULL_PTR orig); /** - * Frees any resources used by the BlindedTail, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new HeldHtlcAvailable-variant AsyncPaymentsMessage */ -void BlindedTail_free(struct LDKBlindedTail this_obj); +struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_held_htlc_available(struct LDKHeldHtlcAvailable a); /** - * The hops of the [`BlindedPaymentPath`] provided by the recipient. + * Utility method to constructs a new ReleaseHeldHtlc-variant AsyncPaymentsMessage */ -struct LDKCVec_BlindedHopZ BlindedTail_get_hops(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_release_held_htlc(struct LDKReleaseHeldHtlc a); /** - * The hops of the [`BlindedPaymentPath`] provided by the recipient. + * Frees any resources used by the HeldHtlcAvailable, if is_owned is set and inner is non-NULL. */ -void BlindedTail_set_hops(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKCVec_BlindedHopZ val); +void HeldHtlcAvailable_free(struct LDKHeldHtlcAvailable this_obj); /** - * The blinding point of the [`BlindedPaymentPath`] provided by the recipient. + * Constructs a new HeldHtlcAvailable given each field */ -struct LDKPublicKey BlindedTail_get_blinding_point(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKHeldHtlcAvailable HeldHtlcAvailable_new(void); /** - * The blinding point of the [`BlindedPaymentPath`] provided by the recipient. + * Creates a copy of the HeldHtlcAvailable */ -void BlindedTail_set_blinding_point(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKHeldHtlcAvailable HeldHtlcAvailable_clone(const struct LDKHeldHtlcAvailable *NONNULL_PTR orig); /** - * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from - * inferring the destination. May be 0. + * Frees any resources used by the ReleaseHeldHtlc, if is_owned is set and inner is non-NULL. */ -uint32_t BlindedTail_get_excess_final_cltv_expiry_delta(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +void ReleaseHeldHtlc_free(struct LDKReleaseHeldHtlc this_obj); /** - * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from - * inferring the destination. May be 0. + * Constructs a new ReleaseHeldHtlc given each field */ -void BlindedTail_set_excess_final_cltv_expiry_delta(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKReleaseHeldHtlc ReleaseHeldHtlc_new(void); /** - * The total amount paid on this [`Path`], excluding the fees. + * Creates a copy of the ReleaseHeldHtlc */ -uint64_t BlindedTail_get_final_value_msat(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +struct LDKReleaseHeldHtlc ReleaseHeldHtlc_clone(const struct LDKReleaseHeldHtlc *NONNULL_PTR orig); /** - * The total amount paid on this [`Path`], excluding the fees. + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -void BlindedTail_set_final_value_msat(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint64_t val); +struct LDKOnionMessageContents ReleaseHeldHtlc_as_OnionMessageContents(const struct LDKReleaseHeldHtlc *NONNULL_PTR this_arg); /** - * Constructs a new BlindedTail given each field + * Serialize the HeldHtlcAvailable object into a byte array which can be read by HeldHtlcAvailable_read */ -MUST_USE_RES struct LDKBlindedTail BlindedTail_new(struct LDKCVec_BlindedHopZ hops_arg, struct LDKPublicKey blinding_point_arg, uint32_t excess_final_cltv_expiry_delta_arg, uint64_t final_value_msat_arg); +struct LDKCVec_u8Z HeldHtlcAvailable_write(const struct LDKHeldHtlcAvailable *NONNULL_PTR obj); /** - * Creates a copy of the BlindedTail + * Read a HeldHtlcAvailable from a byte array, created by HeldHtlcAvailable_write */ -struct LDKBlindedTail BlindedTail_clone(const struct LDKBlindedTail *NONNULL_PTR orig); +struct LDKCResult_HeldHtlcAvailableDecodeErrorZ HeldHtlcAvailable_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the BlindedTail. + * Serialize the ReleaseHeldHtlc object into a byte array which can be read by ReleaseHeldHtlc_read */ -uint64_t BlindedTail_hash(const struct LDKBlindedTail *NONNULL_PTR o); +struct LDKCVec_u8Z ReleaseHeldHtlc_write(const struct LDKReleaseHeldHtlc *NONNULL_PTR obj); /** - * Checks if two BlindedTails contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a ReleaseHeldHtlc from a byte array, created by ReleaseHeldHtlc_write */ -bool BlindedTail_eq(const struct LDKBlindedTail *NONNULL_PTR a, const struct LDKBlindedTail *NONNULL_PTR b); +struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ ReleaseHeldHtlc_read(struct LDKu8slice ser); /** - * Serialize the BlindedTail object into a byte array which can be read by BlindedTail_read + * Returns whether `tlv_type` corresponds to a TLV record for async payment messages. */ -struct LDKCVec_u8Z BlindedTail_write(const struct LDKBlindedTail *NONNULL_PTR obj); +MUST_USE_RES bool AsyncPaymentsMessage_is_known_type(uint64_t tlv_type); /** - * Read a BlindedTail from a byte array, created by BlindedTail_write + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -struct LDKCResult_BlindedTailDecodeErrorZ BlindedTail_read(struct LDKu8slice ser); +struct LDKOnionMessageContents AsyncPaymentsMessage_as_OnionMessageContents(const struct LDKAsyncPaymentsMessage *NONNULL_PTR this_arg); /** - * Frees any resources used by the Path, if is_owned is set and inner is non-NULL. + * Serialize the AsyncPaymentsMessage object into a byte array which can be read by AsyncPaymentsMessage_read */ -void Path_free(struct LDKPath this_obj); +struct LDKCVec_u8Z AsyncPaymentsMessage_write(const struct LDKAsyncPaymentsMessage *NONNULL_PTR obj); /** - * The list of unblinded hops in this [`Path`]. Must be at least length one. + * Read a AsyncPaymentsMessage from a byte array, created by AsyncPaymentsMessage_write */ -struct LDKCVec_RouteHopZ Path_get_hops(const struct LDKPath *NONNULL_PTR this_ptr); +struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ AsyncPaymentsMessage_read(struct LDKu8slice ser, uint64_t arg); /** - * The list of unblinded hops in this [`Path`]. Must be at least length one. + * Calls the free function if one is set */ -void Path_set_hops(struct LDKPath *NONNULL_PTR this_ptr, struct LDKCVec_RouteHopZ val); +void DNSResolverMessageHandler_free(struct LDKDNSResolverMessageHandler this_ptr); /** - * The blinded path at which this path terminates, if we're sending to one, and its metadata. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the DNSResolverMessage */ -struct LDKBlindedTail Path_get_blinded_tail(const struct LDKPath *NONNULL_PTR this_ptr); +void DNSResolverMessage_free(struct LDKDNSResolverMessage this_ptr); /** - * The blinded path at which this path terminates, if we're sending to one, and its metadata. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the DNSResolverMessage */ -void Path_set_blinded_tail(struct LDKPath *NONNULL_PTR this_ptr, struct LDKBlindedTail val); +struct LDKDNSResolverMessage DNSResolverMessage_clone(const struct LDKDNSResolverMessage *NONNULL_PTR orig); /** - * Constructs a new Path given each field - * - * Note that blinded_tail_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new DNSSECQuery-variant DNSResolverMessage */ -MUST_USE_RES struct LDKPath Path_new(struct LDKCVec_RouteHopZ hops_arg, struct LDKBlindedTail blinded_tail_arg); +struct LDKDNSResolverMessage DNSResolverMessage_dnssecquery(struct LDKDNSSECQuery a); /** - * Creates a copy of the Path + * Utility method to constructs a new DNSSECProof-variant DNSResolverMessage */ -struct LDKPath Path_clone(const struct LDKPath *NONNULL_PTR orig); +struct LDKDNSResolverMessage DNSResolverMessage_dnssecproof(struct LDKDNSSECProof a); /** - * Generates a non-cryptographic 64-bit hash of the Path. + * Generates a non-cryptographic 64-bit hash of the DNSResolverMessage. */ -uint64_t Path_hash(const struct LDKPath *NONNULL_PTR o); +uint64_t DNSResolverMessage_hash(const struct LDKDNSResolverMessage *NONNULL_PTR o); /** - * Checks if two Paths contain equal inner contents. + * Checks if two DNSResolverMessages contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. */ -bool Path_eq(const struct LDKPath *NONNULL_PTR a, const struct LDKPath *NONNULL_PTR b); +bool DNSResolverMessage_eq(const struct LDKDNSResolverMessage *NONNULL_PTR a, const struct LDKDNSResolverMessage *NONNULL_PTR b); /** - * Gets the fees for a given path, excluding any excess paid to the recipient. + * Frees any resources used by the DNSSECQuery, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES uint64_t Path_fee_msat(const struct LDKPath *NONNULL_PTR this_arg); +void DNSSECQuery_free(struct LDKDNSSECQuery this_obj); /** - * Gets the total amount paid on this [`Path`], excluding the fees. + * Creates a copy of the DNSSECQuery */ -MUST_USE_RES uint64_t Path_final_value_msat(const struct LDKPath *NONNULL_PTR this_arg); +struct LDKDNSSECQuery DNSSECQuery_clone(const struct LDKDNSSECQuery *NONNULL_PTR orig); /** - * Gets the final hop's CLTV expiry delta. + * Generates a non-cryptographic 64-bit hash of the DNSSECQuery. */ -MUST_USE_RES struct LDKCOption_u32Z Path_final_cltv_expiry_delta(const struct LDKPath *NONNULL_PTR this_arg); +uint64_t DNSSECQuery_hash(const struct LDKDNSSECQuery *NONNULL_PTR o); /** - * Frees any resources used by the Route, if is_owned is set and inner is non-NULL. + * Checks if two DNSSECQuerys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void Route_free(struct LDKRoute this_obj); +bool DNSSECQuery_eq(const struct LDKDNSSECQuery *NONNULL_PTR a, const struct LDKDNSSECQuery *NONNULL_PTR b); /** - * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no - * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be - * the same. + * Frees any resources used by the DNSSECProof, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_PathZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); +void DNSSECProof_free(struct LDKDNSSECProof this_obj); /** - * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no - * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be - * the same. + * An [RFC 9102 DNSSEC AuthenticationChain] providing a DNSSEC proof. + * + * [RFC 9102 DNSSEC AuthenticationChain]: https://www.rfc-editor.org/rfc/rfc9102.html#name-dnssec-authentication-chain + * + * Returns a copy of the field. */ -void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_PathZ val); +struct LDKCVec_u8Z DNSSECProof_get_proof(const struct LDKDNSSECProof *NONNULL_PTR this_ptr); /** - * The `route_params` parameter passed to [`find_route`]. - * - * This is used by `ChannelManager` to track information which may be required for retries. - * - * Will be `None` for objects serialized with LDK versions prior to 0.0.117. + * An [RFC 9102 DNSSEC AuthenticationChain] providing a DNSSEC proof. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [RFC 9102 DNSSEC AuthenticationChain]: https://www.rfc-editor.org/rfc/rfc9102.html#name-dnssec-authentication-chain */ -struct LDKRouteParameters Route_get_route_params(const struct LDKRoute *NONNULL_PTR this_ptr); +void DNSSECProof_set_proof(struct LDKDNSSECProof *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * The `route_params` parameter passed to [`find_route`]. - * - * This is used by `ChannelManager` to track information which may be required for retries. - * - * Will be `None` for objects serialized with LDK versions prior to 0.0.117. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the DNSSECProof */ -void Route_set_route_params(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKRouteParameters val); +struct LDKDNSSECProof DNSSECProof_clone(const struct LDKDNSSECProof *NONNULL_PTR orig); /** - * Constructs a new Route given each field - * - * Note that route_params_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Generates a non-cryptographic 64-bit hash of the DNSSECProof. */ -MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_PathZ paths_arg, struct LDKRouteParameters route_params_arg); +uint64_t DNSSECProof_hash(const struct LDKDNSSECProof *NONNULL_PTR o); /** - * Creates a copy of the Route + * Checks if two DNSSECProofs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); +bool DNSSECProof_eq(const struct LDKDNSSECProof *NONNULL_PTR a, const struct LDKDNSSECProof *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the Route. + * Returns whether `tlv_type` corresponds to a TLV record for DNS Resolvers. */ -uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o); +MUST_USE_RES bool DNSResolverMessage_is_known_type(uint64_t tlv_type); /** - * Checks if two Routes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the DNSResolverMessage object into a byte array which can be read by DNSResolverMessage_read */ -bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNULL_PTR b); +struct LDKCVec_u8Z DNSResolverMessage_write(const struct LDKDNSResolverMessage *NONNULL_PTR obj); /** - * Returns the total amount of fees paid on this [`Route`]. - * - * For objects serialized with LDK 0.0.117 and after, this includes any extra payment made to - * the recipient, which can happen in excess of the amount passed to [`find_route`] via - * [`RouteParameters::final_value_msat`], if we had to reach the [`htlc_minimum_msat`] limits. - * - * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + * Read a DNSResolverMessage from a byte array, created by DNSResolverMessage_write */ -MUST_USE_RES uint64_t Route_get_total_fees(const struct LDKRoute *NONNULL_PTR this_arg); +struct LDKCResult_DNSResolverMessageDecodeErrorZ DNSResolverMessage_read(struct LDKu8slice ser, uint64_t arg); /** - * Returns the total amount paid on this [`Route`], excluding the fees. - * - * Might be more than requested as part of the given [`RouteParameters::final_value_msat`] if - * we had to reach the [`htlc_minimum_msat`] limits. - * - * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg); +struct LDKOnionMessageContents DNSResolverMessage_as_OnionMessageContents(const struct LDKDNSResolverMessage *NONNULL_PTR this_arg); /** - * Get the string representation of a Route object + * Frees any resources used by the HumanReadableName, if is_owned is set and inner is non-NULL. */ -struct LDKStr Route_to_str(const struct LDKRoute *NONNULL_PTR o); +void HumanReadableName_free(struct LDKHumanReadableName this_obj); /** - * Serialize the Route object into a byte array which can be read by Route_read + * Creates a copy of the HumanReadableName */ -struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); +struct LDKHumanReadableName HumanReadableName_clone(const struct LDKHumanReadableName *NONNULL_PTR orig); /** - * Read a Route from a byte array, created by Route_write + * Generates a non-cryptographic 64-bit hash of the HumanReadableName. */ -struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); +uint64_t HumanReadableName_hash(const struct LDKHumanReadableName *NONNULL_PTR o); /** - * Frees any resources used by the RouteParameters, if is_owned is set and inner is non-NULL. + * Checks if two HumanReadableNames contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void RouteParameters_free(struct LDKRouteParameters this_obj); +bool HumanReadableName_eq(const struct LDKHumanReadableName *NONNULL_PTR a, const struct LDKHumanReadableName *NONNULL_PTR b); /** - * The parameters of the failed payment path. + * Constructs a new [`HumanReadableName`] from the `user` and `domain` parts. See the + * struct-level documentation for more on the requirements on each. */ -struct LDKPaymentParameters RouteParameters_get_payment_params(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_HumanReadableNameNoneZ HumanReadableName_new(struct LDKStr user, struct LDKStr domain); /** - * The parameters of the failed payment path. + * Constructs a new [`HumanReadableName`] from the standard encoding - `user`@`domain`. + * + * If `user` includes the standard BIP 353 â‚¿ prefix it is automatically removed as required by + * BIP 353. */ -void RouteParameters_set_payment_params(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); +MUST_USE_RES struct LDKCResult_HumanReadableNameNoneZ HumanReadableName_from_encoded(struct LDKStr encoded); /** - * The amount in msats sent on the failed payment path. + * Gets the `user` part of this Human Readable Name */ -uint64_t RouteParameters_get_final_value_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKStr HumanReadableName_user(const struct LDKHumanReadableName *NONNULL_PTR this_arg); /** - * The amount in msats sent on the failed payment path. + * Gets the `domain` part of this Human Readable Name */ -void RouteParameters_set_final_value_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKStr HumanReadableName_domain(const struct LDKHumanReadableName *NONNULL_PTR this_arg); /** - * The maximum total fees, in millisatoshi, that may accrue during route finding. - * - * This limit also applies to the total fees that may arise while retrying failed payment - * paths. - * - * Note that values below a few sats may result in some paths being spuriously ignored. + * Serialize the HumanReadableName object into a byte array which can be read by HumanReadableName_read */ -struct LDKCOption_u64Z RouteParameters_get_max_total_routing_fee_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z HumanReadableName_write(const struct LDKHumanReadableName *NONNULL_PTR obj); /** - * The maximum total fees, in millisatoshi, that may accrue during route finding. - * - * This limit also applies to the total fees that may arise while retrying failed payment - * paths. - * - * Note that values below a few sats may result in some paths being spuriously ignored. + * Read a HumanReadableName from a byte array, created by HumanReadableName_write */ -void RouteParameters_set_max_total_routing_fee_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKCResult_HumanReadableNameDecodeErrorZ HumanReadableName_read(struct LDKu8slice ser); /** - * Constructs a new RouteParameters given each field + * Frees any resources used by the OMNameResolver, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPaymentParameters payment_params_arg, uint64_t final_value_msat_arg, struct LDKCOption_u64Z max_total_routing_fee_msat_arg); +void OMNameResolver_free(struct LDKOMNameResolver this_obj); /** - * Creates a copy of the RouteParameters + * Builds a new [`OMNameResolver`]. */ -struct LDKRouteParameters RouteParameters_clone(const struct LDKRouteParameters *NONNULL_PTR orig); +MUST_USE_RES struct LDKOMNameResolver OMNameResolver_new(uint32_t latest_block_time, uint32_t latest_block_height); /** - * Generates a non-cryptographic 64-bit hash of the RouteParameters. + * Informs the [`OMNameResolver`] of the passage of time in the form of a new best Bitcoin + * block. + * + * This will call back to resolve some pending queries which have timed out. */ -uint64_t RouteParameters_hash(const struct LDKRouteParameters *NONNULL_PTR o); +void OMNameResolver_new_best_block(const struct LDKOMNameResolver *NONNULL_PTR this_arg, uint32_t height, uint32_t time); /** - * Checks if two RouteParameterss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Begins the process of resolving a BIP 353 Human Readable Name. + * + * Returns a [`DNSSECQuery`] onion message and a [`DNSResolverContext`] which should be sent + * to a resolver (with the context used to generate the blinded response path) on success. */ -bool RouteParameters_eq(const struct LDKRouteParameters *NONNULL_PTR a, const struct LDKRouteParameters *NONNULL_PTR b); +MUST_USE_RES struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ OMNameResolver_resolve_name(const struct LDKOMNameResolver *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id, struct LDKHumanReadableName name, const struct LDKEntropySource *NONNULL_PTR entropy_source); /** - * Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount. + * Handles a [`DNSSECProof`] message, attempting to verify it and match it against a pending + * query. * - * [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats + * If verification succeeds, the resulting bitcoin: URI is parsed to find a contained + * [`Offer`]. + * + * Note that a single proof for a wildcard DNS entry may complete several requests for + * different [`HumanReadableName`]s. + * + * If an [`Offer`] is found, it, as well as the [`PaymentId`] and original `name` passed to + * [`Self::resolve_name`] are returned. */ -MUST_USE_RES struct LDKRouteParameters RouteParameters_from_payment_params_and_value(struct LDKPaymentParameters payment_params, uint64_t final_value_msat); +MUST_USE_RES struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ OMNameResolver_handle_dnssec_proof_for_offer(const struct LDKOMNameResolver *NONNULL_PTR this_arg, struct LDKDNSSECProof msg, struct LDKDNSResolverContext context); /** - * Sets the maximum number of hops that can be included in a payment path, based on the provided - * [`RecipientOnionFields`] and blinded paths. + * Handles a [`DNSSECProof`] message, attempting to verify it and match it against any pending + * queries. + * + * If verification succeeds, all matching [`PaymentId`] and [`HumanReadableName`]s passed to + * [`Self::resolve_name`], as well as the resolved bitcoin: URI are returned. + * + * Note that a single proof for a wildcard DNS entry may complete several requests for + * different [`HumanReadableName`]s. + * + * This method is useful for those who handle bitcoin: URIs already, handling more than just + * BOLT12 [`Offer`]s. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ RouteParameters_set_max_path_length(struct LDKRouteParameters *NONNULL_PTR this_arg, const struct LDKRecipientOnionFields *NONNULL_PTR recipient_onion, bool is_keysend, uint32_t best_block_height); +MUST_USE_RES struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ OMNameResolver_handle_dnssec_proof_for_uri(const struct LDKOMNameResolver *NONNULL_PTR this_arg, struct LDKDNSSECProof msg, struct LDKDNSResolverContext context); /** - * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read + * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z RouteParameters_write(const struct LDKRouteParameters *NONNULL_PTR obj); +void OnionMessenger_free(struct LDKOnionMessenger this_obj); /** - * Read a RouteParameters from a byte array, created by RouteParameters_write + * Frees any resources used by the Responder, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_RouteParametersDecodeErrorZ RouteParameters_read(struct LDKu8slice ser); +void Responder_free(struct LDKResponder this_obj); /** - * Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL. + * Creates a copy of the Responder */ -void PaymentParameters_free(struct LDKPaymentParameters this_obj); +struct LDKResponder Responder_clone(const struct LDKResponder *NONNULL_PTR orig); /** - * Information about the payee, such as their features and route hints for their channels. + * Checks if two Responders contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKPayee PaymentParameters_get_payee(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +bool Responder_eq(const struct LDKResponder *NONNULL_PTR a, const struct LDKResponder *NONNULL_PTR b); /** - * Information about the payee, such as their features and route hints for their channels. + * Serialize the Responder object into a byte array which can be read by Responder_read */ -void PaymentParameters_set_payee(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKPayee val); +struct LDKCVec_u8Z Responder_write(const struct LDKResponder *NONNULL_PTR obj); /** - * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. + * Read a Responder from a byte array, created by Responder_write */ -struct LDKCOption_u64Z PaymentParameters_get_expiry_time(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKCResult_ResponderDecodeErrorZ Responder_read(struct LDKu8slice ser); /** - * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. + * Creates a [`ResponseInstruction`] for responding without including a reply path. + * + * Use when the recipient doesn't need to send back a reply to us. */ -void PaymentParameters_set_expiry_time(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKResponseInstruction Responder_respond(struct LDKResponder this_arg); /** - * The maximum total CLTV delta we accept for the route. - * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. + * Creates a [`ResponseInstruction`] for responding including a reply path. + * + * Use when the recipient needs to send back a reply to us. */ -uint32_t PaymentParameters_get_max_total_cltv_expiry_delta(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKResponseInstruction Responder_respond_with_reply_path(struct LDKResponder this_arg, struct LDKMessageContext context); /** - * The maximum total CLTV delta we accept for the route. - * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. + * Frees any resources used by the ResponseInstruction, if is_owned is set and inner is non-NULL. */ -void PaymentParameters_set_max_total_cltv_expiry_delta(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint32_t val); +void ResponseInstruction_free(struct LDKResponseInstruction this_obj); /** - * The maximum number of paths that may be used by (MPP) payments. - * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + * Creates a copy of the ResponseInstruction */ -uint8_t PaymentParameters_get_max_path_count(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKResponseInstruction ResponseInstruction_clone(const struct LDKResponseInstruction *NONNULL_PTR orig); /** - * The maximum number of paths that may be used by (MPP) payments. - * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + * Converts this [`ResponseInstruction`] into a [`MessageSendInstructions`] so that it can be + * used to send the response via a normal message sending method. */ -void PaymentParameters_set_max_path_count(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); +MUST_USE_RES struct LDKMessageSendInstructions ResponseInstruction_into_instructions(struct LDKResponseInstruction this_arg); /** - * The maximum number of [`Path::hops`] in any returned path. - * Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. + * Frees any resources used by the MessageSendInstructions */ -uint8_t PaymentParameters_get_max_path_length(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +void MessageSendInstructions_free(struct LDKMessageSendInstructions this_ptr); /** - * The maximum number of [`Path::hops`] in any returned path. - * Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. + * Creates a copy of the MessageSendInstructions */ -void PaymentParameters_set_max_path_length(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); +struct LDKMessageSendInstructions MessageSendInstructions_clone(const struct LDKMessageSendInstructions *NONNULL_PTR orig); /** - * Selects the maximum share of a channel's total capacity which will be sent over a channel, - * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas - * a lower value prefers to send larger MPP parts, potentially saturating channels and - * increasing failure probability for those paths. - * - * Note that this restriction will be relaxed during pathfinding after paths which meet this - * restriction have been found. While paths which meet this criteria will be searched for, it - * is ultimately up to the scorer to select them over other paths. - * - * A value of 0 will allow payments up to and including a channel's total announced usable - * capacity, a value of one will only use up to half its capacity, two 1/4, etc. - * - * Default value: 2 + * Utility method to constructs a new WithSpecifiedReplyPath-variant MessageSendInstructions */ -uint8_t PaymentParameters_get_max_channel_saturation_power_of_half(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKMessageSendInstructions MessageSendInstructions_with_specified_reply_path(struct LDKDestination destination, struct LDKBlindedMessagePath reply_path); /** - * Selects the maximum share of a channel's total capacity which will be sent over a channel, - * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas - * a lower value prefers to send larger MPP parts, potentially saturating channels and - * increasing failure probability for those paths. - * - * Note that this restriction will be relaxed during pathfinding after paths which meet this - * restriction have been found. While paths which meet this criteria will be searched for, it - * is ultimately up to the scorer to select them over other paths. - * - * A value of 0 will allow payments up to and including a channel's total announced usable - * capacity, a value of one will only use up to half its capacity, two 1/4, etc. - * - * Default value: 2 + * Utility method to constructs a new WithReplyPath-variant MessageSendInstructions */ -void PaymentParameters_set_max_channel_saturation_power_of_half(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); +struct LDKMessageSendInstructions MessageSendInstructions_with_reply_path(struct LDKDestination destination, struct LDKMessageContext context); /** - * A list of SCIDs which this payment was previously attempted over and which caused the - * payment to fail. Future attempts for the same payment shouldn't be relayed through any of - * these SCIDs. - * - * Returns a copy of the field. + * Utility method to constructs a new WithoutReplyPath-variant MessageSendInstructions */ -struct LDKCVec_u64Z PaymentParameters_get_previously_failed_channels(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKMessageSendInstructions MessageSendInstructions_without_reply_path(struct LDKDestination destination); /** - * A list of SCIDs which this payment was previously attempted over and which caused the - * payment to fail. Future attempts for the same payment shouldn't be relayed through any of - * these SCIDs. + * Utility method to constructs a new ForReply-variant MessageSendInstructions */ -void PaymentParameters_set_previously_failed_channels(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +struct LDKMessageSendInstructions MessageSendInstructions_for_reply(struct LDKResponseInstruction instructions); /** - * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this - * payment was previously attempted over and which caused the payment to fail. Future attempts - * for the same payment shouldn't be relayed through any of these blinded paths. - * - * Returns a copy of the field. + * Calls the free function if one is set */ -struct LDKCVec_u64Z PaymentParameters_get_previously_failed_blinded_path_idxs(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +void MessageRouter_free(struct LDKMessageRouter this_ptr); /** - * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this - * payment was previously attempted over and which caused the payment to fail. Future attempts - * for the same payment shouldn't be relayed through any of these blinded paths. + * Frees any resources used by the DefaultMessageRouter, if is_owned is set and inner is non-NULL. */ -void PaymentParameters_set_previously_failed_blinded_path_idxs(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +void DefaultMessageRouter_free(struct LDKDefaultMessageRouter this_obj); /** - * Constructs a new PaymentParameters given each field + * Creates a [`DefaultMessageRouter`] using the given [`NetworkGraph`]. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPayee payee_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg, uint8_t max_path_count_arg, uint8_t max_path_length_arg, uint8_t max_channel_saturation_power_of_half_arg, struct LDKCVec_u64Z previously_failed_channels_arg, struct LDKCVec_u64Z previously_failed_blinded_path_idxs_arg); +MUST_USE_RES struct LDKDefaultMessageRouter DefaultMessageRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKEntropySource entropy_source); /** - * Creates a copy of the PaymentParameters + * Constructs a new MessageRouter which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageRouter must be freed before this_arg is */ -struct LDKPaymentParameters PaymentParameters_clone(const struct LDKPaymentParameters *NONNULL_PTR orig); +struct LDKMessageRouter DefaultMessageRouter_as_MessageRouter(const struct LDKDefaultMessageRouter *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the PaymentParameters. + * Frees any resources used by the OnionMessagePath, if is_owned is set and inner is non-NULL. */ -uint64_t PaymentParameters_hash(const struct LDKPaymentParameters *NONNULL_PTR o); +void OnionMessagePath_free(struct LDKOnionMessagePath this_obj); /** - * Checks if two PaymentParameterss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Nodes on the path between the sender and the destination. + * + * Returns a copy of the field. */ -bool PaymentParameters_eq(const struct LDKPaymentParameters *NONNULL_PTR a, const struct LDKPaymentParameters *NONNULL_PTR b); +struct LDKCVec_PublicKeyZ OnionMessagePath_get_intermediate_nodes(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); /** - * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read + * Nodes on the path between the sender and the destination. */ -struct LDKCVec_u8Z PaymentParameters_write(const struct LDKPaymentParameters *NONNULL_PTR obj); +void OnionMessagePath_set_intermediate_nodes(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCVec_PublicKeyZ val); /** - * Read a PaymentParameters from a byte array, created by PaymentParameters_write + * The recipient of the message. */ -struct LDKCResult_PaymentParametersDecodeErrorZ PaymentParameters_read(struct LDKu8slice ser, uint32_t arg); +struct LDKDestination OnionMessagePath_get_destination(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); /** - * Creates a payee with the node id of the given `pubkey`. - * - * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has - * provided. + * The recipient of the message. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_node_id(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta); +void OnionMessagePath_set_destination(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKDestination val); /** - * Creates a payee with the node id of the given `pubkey` to use for keysend payments. - * - * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has - * provided. + * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. * - * Note that MPP keysend is not widely supported yet. The `allow_mpp` lets you choose - * whether your router will be allowed to find a multi-part route for this payment. If you - * set `allow_mpp` to true, you should ensure a payment secret is set on send, likely via - * [`RecipientOnionFields::secret_only`]. + * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use + * this to initiate such a connection. * - * [`RecipientOnionFields::secret_only`]: crate::ln::channelmanager::RecipientOnionFields::secret_only + * Returns a copy of the field. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_for_keysend(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta, bool allow_mpp); +struct LDKCOption_CVec_SocketAddressZZ OnionMessagePath_get_first_node_addresses(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); /** - * Creates parameters for paying to a blinded payee from the provided invoice. Sets - * [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and - * [`PaymentParameters::expiry_time`]. + * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. + * + * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use + * this to initiate such a connection. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_bolt12_invoice(const struct LDKBolt12Invoice *NONNULL_PTR invoice); +void OnionMessagePath_set_first_node_addresses(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCOption_CVec_SocketAddressZZ val); /** - * Creates parameters for paying to a blinded payee from the provided blinded route hints. + * Constructs a new OnionMessagePath given each field */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_blinded(struct LDKCVec_BlindedPaymentPathZ blinded_route_hints); +MUST_USE_RES struct LDKOnionMessagePath OnionMessagePath_new(struct LDKCVec_PublicKeyZ intermediate_nodes_arg, struct LDKDestination destination_arg, struct LDKCOption_CVec_SocketAddressZZ first_node_addresses_arg); /** - * Frees any resources used by the Payee + * Creates a copy of the OnionMessagePath */ -void Payee_free(struct LDKPayee this_ptr); +struct LDKOnionMessagePath OnionMessagePath_clone(const struct LDKOnionMessagePath *NONNULL_PTR orig); /** - * Creates a copy of the Payee + * Returns the first node in the path. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKPayee Payee_clone(const struct LDKPayee *NONNULL_PTR orig); +MUST_USE_RES struct LDKPublicKey OnionMessagePath_first_node(const struct LDKOnionMessagePath *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Blinded-variant Payee + * Frees any resources used by the Destination */ -struct LDKPayee Payee_blinded(struct LDKCVec_BlindedPaymentPathZ route_hints, struct LDKBolt12InvoiceFeatures features); +void Destination_free(struct LDKDestination this_ptr); /** - * Utility method to constructs a new Clear-variant Payee + * Creates a copy of the Destination */ -struct LDKPayee Payee_clear(struct LDKPublicKey node_id, struct LDKCVec_RouteHintZ route_hints, struct LDKBolt11InvoiceFeatures features, uint32_t final_cltv_expiry_delta); +struct LDKDestination Destination_clone(const struct LDKDestination *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the Payee. + * Utility method to constructs a new Node-variant Destination */ -uint64_t Payee_hash(const struct LDKPayee *NONNULL_PTR o); +struct LDKDestination Destination_node(struct LDKPublicKey a); /** - * Checks if two Payees contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Utility method to constructs a new BlindedPath-variant Destination */ -bool Payee_eq(const struct LDKPayee *NONNULL_PTR a, const struct LDKPayee *NONNULL_PTR b); +struct LDKDestination Destination_blinded_path(struct LDKBlindedMessagePath a); /** - * Serialize the RouteHint object into a byte array which can be read by RouteHint_read + * Generates a non-cryptographic 64-bit hash of the Destination. */ -struct LDKCVec_u8Z RouteHint_write(const struct LDKRouteHint *NONNULL_PTR obj); +uint64_t Destination_hash(const struct LDKDestination *NONNULL_PTR o); /** - * Read a RouteHint from a byte array, created by RouteHint_write + * Checks if two Destinations contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCResult_RouteHintDecodeErrorZ RouteHint_read(struct LDKu8slice ser); +bool Destination_eq(const struct LDKDestination *NONNULL_PTR a, const struct LDKDestination *NONNULL_PTR b); /** - * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read + * Attempts to resolve the [`IntroductionNode::DirectedShortChannelId`] of a + * [`Destination::BlindedPath`] to a [`IntroductionNode::NodeId`], if applicable, using the + * provided [`ReadOnlyNetworkGraph`]. */ -struct LDKCVec_u8Z RouteHintHop_write(const struct LDKRouteHintHop *NONNULL_PTR obj); +void Destination_resolve(struct LDKDestination *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); /** - * Read a RouteHintHop from a byte array, created by RouteHintHop_write + * Frees any resources used by the SendSuccess */ -struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice ser); +void SendSuccess_free(struct LDKSendSuccess this_ptr); /** - * Frees any resources used by the FirstHopCandidate, if is_owned is set and inner is non-NULL. + * Creates a copy of the SendSuccess */ -void FirstHopCandidate_free(struct LDKFirstHopCandidate this_obj); +struct LDKSendSuccess SendSuccess_clone(const struct LDKSendSuccess *NONNULL_PTR orig); /** - * Creates a copy of the FirstHopCandidate + * Utility method to constructs a new Buffered-variant SendSuccess */ -struct LDKFirstHopCandidate FirstHopCandidate_clone(const struct LDKFirstHopCandidate *NONNULL_PTR orig); +struct LDKSendSuccess SendSuccess_buffered(void); /** - * Frees any resources used by the PublicHopCandidate, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new BufferedAwaitingConnection-variant SendSuccess */ -void PublicHopCandidate_free(struct LDKPublicHopCandidate this_obj); +struct LDKSendSuccess SendSuccess_buffered_awaiting_connection(struct LDKPublicKey a); /** - * The short channel ID of the channel, i.e. the identifier by which we refer to this - * channel. + * Generates a non-cryptographic 64-bit hash of the SendSuccess. */ -uint64_t PublicHopCandidate_get_short_channel_id(const struct LDKPublicHopCandidate *NONNULL_PTR this_ptr); +uint64_t SendSuccess_hash(const struct LDKSendSuccess *NONNULL_PTR o); /** - * The short channel ID of the channel, i.e. the identifier by which we refer to this - * channel. + * Checks if two SendSuccesss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void PublicHopCandidate_set_short_channel_id(struct LDKPublicHopCandidate *NONNULL_PTR this_ptr, uint64_t val); +bool SendSuccess_eq(const struct LDKSendSuccess *NONNULL_PTR a, const struct LDKSendSuccess *NONNULL_PTR b); /** - * Creates a copy of the PublicHopCandidate + * Frees any resources used by the SendError */ -struct LDKPublicHopCandidate PublicHopCandidate_clone(const struct LDKPublicHopCandidate *NONNULL_PTR orig); +void SendError_free(struct LDKSendError this_ptr); /** - * Frees any resources used by the PrivateHopCandidate, if is_owned is set and inner is non-NULL. + * Creates a copy of the SendError */ -void PrivateHopCandidate_free(struct LDKPrivateHopCandidate this_obj); +struct LDKSendError SendError_clone(const struct LDKSendError *NONNULL_PTR orig); /** - * Creates a copy of the PrivateHopCandidate + * Utility method to constructs a new Secp256k1-variant SendError */ -struct LDKPrivateHopCandidate PrivateHopCandidate_clone(const struct LDKPrivateHopCandidate *NONNULL_PTR orig); +struct LDKSendError SendError_secp256k1(enum LDKSecp256k1Error a); /** - * Frees any resources used by the BlindedPathCandidate, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new TooBigPacket-variant SendError */ -void BlindedPathCandidate_free(struct LDKBlindedPathCandidate this_obj); +struct LDKSendError SendError_too_big_packet(void); /** - * Creates a copy of the BlindedPathCandidate + * Utility method to constructs a new TooFewBlindedHops-variant SendError */ -struct LDKBlindedPathCandidate BlindedPathCandidate_clone(const struct LDKBlindedPathCandidate *NONNULL_PTR orig); +struct LDKSendError SendError_too_few_blinded_hops(void); /** - * Frees any resources used by the OneHopBlindedPathCandidate, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new InvalidFirstHop-variant SendError */ -void OneHopBlindedPathCandidate_free(struct LDKOneHopBlindedPathCandidate this_obj); +struct LDKSendError SendError_invalid_first_hop(struct LDKPublicKey a); /** - * Creates a copy of the OneHopBlindedPathCandidate + * Utility method to constructs a new PathNotFound-variant SendError */ -struct LDKOneHopBlindedPathCandidate OneHopBlindedPathCandidate_clone(const struct LDKOneHopBlindedPathCandidate *NONNULL_PTR orig); +struct LDKSendError SendError_path_not_found(void); /** - * Frees any resources used by the CandidateRouteHop + * Utility method to constructs a new InvalidMessage-variant SendError */ -void CandidateRouteHop_free(struct LDKCandidateRouteHop this_ptr); +struct LDKSendError SendError_invalid_message(void); /** - * Creates a copy of the CandidateRouteHop + * Utility method to constructs a new BufferFull-variant SendError */ -struct LDKCandidateRouteHop CandidateRouteHop_clone(const struct LDKCandidateRouteHop *NONNULL_PTR orig); +struct LDKSendError SendError_buffer_full(void); /** - * Utility method to constructs a new FirstHop-variant CandidateRouteHop + * Utility method to constructs a new GetNodeIdFailed-variant SendError */ -struct LDKCandidateRouteHop CandidateRouteHop_first_hop(struct LDKFirstHopCandidate a); +struct LDKSendError SendError_get_node_id_failed(void); /** - * Utility method to constructs a new PublicHop-variant CandidateRouteHop + * Utility method to constructs a new UnresolvedIntroductionNode-variant SendError */ -struct LDKCandidateRouteHop CandidateRouteHop_public_hop(struct LDKPublicHopCandidate a); +struct LDKSendError SendError_unresolved_introduction_node(void); /** - * Utility method to constructs a new PrivateHop-variant CandidateRouteHop + * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError */ -struct LDKCandidateRouteHop CandidateRouteHop_private_hop(struct LDKPrivateHopCandidate a); +struct LDKSendError SendError_blinded_path_advance_failed(void); /** - * Utility method to constructs a new Blinded-variant CandidateRouteHop + * Generates a non-cryptographic 64-bit hash of the SendError. */ -struct LDKCandidateRouteHop CandidateRouteHop_blinded(struct LDKBlindedPathCandidate a); +uint64_t SendError_hash(const struct LDKSendError *NONNULL_PTR o); /** - * Utility method to constructs a new OneHopBlinded-variant CandidateRouteHop + * Checks if two SendErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCandidateRouteHop CandidateRouteHop_one_hop_blinded(struct LDKOneHopBlindedPathCandidate a); +bool SendError_eq(const struct LDKSendError *NONNULL_PTR a, const struct LDKSendError *NONNULL_PTR b); /** - * Returns the globally unique short channel ID for this hop, if one is known. - * - * This only returns `Some` if the channel is public (either our own, or one we've learned - * from the public network graph), and thus the short channel ID we have for this channel is - * globally unique and identifies this channel in a global namespace. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKCOption_u64Z CandidateRouteHop_globally_unique_short_channel_id(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +void CustomOnionMessageHandler_free(struct LDKCustomOnionMessageHandler this_ptr); /** - * Returns the required difference in HTLC CLTV expiry between the [`Self::source`] and the - * next-hop for an HTLC taking this hop. - * - * This is the time that the node(s) in this hop have to claim the HTLC on-chain if the - * next-hop goes on chain with a payment preimage. + * Frees any resources used by the PeeledOnion */ -MUST_USE_RES uint32_t CandidateRouteHop_cltv_expiry_delta(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +void PeeledOnion_free(struct LDKPeeledOnion this_ptr); /** - * Returns the minimum amount that can be sent over this hop, in millisatoshis. + * Creates a copy of the PeeledOnion */ -MUST_USE_RES uint64_t CandidateRouteHop_htlc_minimum_msat(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +struct LDKPeeledOnion PeeledOnion_clone(const struct LDKPeeledOnion *NONNULL_PTR orig); /** - * Returns the fees that must be paid to route an HTLC over this channel. + * Utility method to constructs a new Forward-variant PeeledOnion */ -MUST_USE_RES struct LDKRoutingFees CandidateRouteHop_fees(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +struct LDKPeeledOnion PeeledOnion_forward(struct LDKNextMessageHop a, struct LDKOnionMessage b); /** - * Returns the source node id of current hop. - * - * Source node id refers to the node forwarding the HTLC through this hop. - * - * For [`Self::FirstHop`] we return payer's node id. + * Utility method to constructs a new Receive-variant PeeledOnion */ -MUST_USE_RES struct LDKNodeId CandidateRouteHop_source(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +struct LDKPeeledOnion PeeledOnion_receive(struct LDKParsedOnionMessageContents a, struct LDKCOption_MessageContextZ b, struct LDKBlindedMessagePath c); /** - * Returns the target node id of this hop, if known. - * - * Target node id refers to the node receiving the HTLC after this hop. - * - * For [`Self::Blinded`] we return `None` because the ultimate destination after the blinded - * path is unknown. + * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of + * `path`, first calling [`Destination::resolve`] on `path.destination` with the given + * [`ReadOnlyNetworkGraph`]. * - * For [`Self::OneHopBlinded`] we return `None` because the target is the same as the source, - * and such a return value would be somewhat nonsensical. + * Returns the node id of the peer to send the message to, the message itself, and any addresses + * needed to connect to the first node. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKNodeId CandidateRouteHop_target(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message_resolving_destination(const struct LDKEntropySource *NONNULL_PTR entropy_source, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph, struct LDKOnionMessagePath path, struct LDKOnionMessageContents contents, struct LDKBlindedMessagePath reply_path); /** - * Finds a route from us (payer) to the given target node (payee). - * - * If the payee provided features in their invoice, they should be provided via the `payee` field - * in the given [`RouteParameters::payment_params`]. - * Without this, MPP will only be used if the payee's features are available in the network graph. - * - * Private routing paths between a public node and the target may be included in the `payee` field - * of [`RouteParameters::payment_params`]. - * - * If some channels aren't announced, it may be useful to fill in `first_hops` with the results - * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels - * from `network_graph` will be ignored, and only those in `first_hops` will be used. - * - * The fees on channels from us to the next hop are ignored as they are assumed to all be equal. - * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` / - * `htlc_maximum_msat` *are* checked as they may change based on the receiving node. - * - * # Panics + * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of + * `path`. * - * Panics if first_hops contains channels without `short_channel_id`s; - * [`ChannelManager::list_usable_channels`] will never include such channels. + * Returns the node id of the peer to send the message to, the message itself, and any addresses + * needed to connect to the first node. * - * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels - * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed - * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + * Returns [`SendError::UnresolvedIntroductionNode`] if: + * - `destination` contains a blinded path with an [`IntroductionNode::DirectedShortChannelId`], + * - unless it can be resolved by [`NodeIdLookUp::next_node_id`]. + * Use [`create_onion_message_resolving_destination`] instead to resolve the introduction node + * first with a [`ReadOnlyNetworkGraph`]. * - * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScoreLookUp *NONNULL_PTR scorer, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params, const uint8_t (*random_seed_bytes)[32]); +struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message(const struct LDKEntropySource *NONNULL_PTR entropy_source, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup, struct LDKOnionMessagePath path, struct LDKOnionMessageContents contents, struct LDKBlindedMessagePath reply_path); /** - * Construct a route from us (payer) to the target node (payee) via the given hops (which should - * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path. + * Decode one layer of an incoming [`OnionMessage`]. * - * Re-uses logic from `find_route`, so the restrictions described there also apply here. - */ -struct LDKCResult_RouteLightningErrorZ build_route_from_hops(struct LDKPublicKey our_node_pubkey, struct LDKCVec_PublicKeyZ hops, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, const uint8_t (*random_seed_bytes)[32]); - -/** - * Calls the free function if one is set - */ -void ScoreLookUp_free(struct LDKScoreLookUp this_ptr); - -/** - * Calls the free function if one is set + * Returns either the next layer of the onion for forwarding or the decrypted content for the + * receiver. */ -void ScoreUpdate_free(struct LDKScoreUpdate this_ptr); +struct LDKCResult_PeeledOnionNoneZ peel_onion_message(const struct LDKOnionMessage *NONNULL_PTR msg, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler); /** - * Calls the free function if one is set + * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to + * their respective handlers. */ -void Score_free(struct LDKScore this_ptr); +MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKNodeIdLookUp node_id_lookup, struct LDKMessageRouter message_router, struct LDKOffersMessageHandler offers_handler, struct LDKAsyncPaymentsMessageHandler async_payments_handler, struct LDKDNSResolverMessageHandler dns_resolver, struct LDKCustomOnionMessageHandler custom_handler); /** - * Calls the free function if one is set + * Similar to [`Self::new`], but rather than dropping onion messages that are + * intended to be forwarded to offline peers, we will intercept them for + * later forwarding. + * + * Interception flow: + * 1. If an onion message for an offline peer is received, `OnionMessenger` will + * generate an [`Event::OnionMessageIntercepted`]. Event handlers can + * then choose to persist this onion message for later forwarding, or drop + * it. + * 2. When the offline peer later comes back online, `OnionMessenger` will + * generate an [`Event::OnionMessagePeerConnected`]. Event handlers will + * then fetch all previously intercepted onion messages for this peer. + * 3. Once the stored onion messages are fetched, they can finally be + * forwarded to the now-online peer via [`Self::forward_onion_message`]. + * + * # Note + * + * LDK will not rate limit how many [`Event::OnionMessageIntercepted`]s + * are generated, so it is the caller's responsibility to limit how many + * onion messages are persisted and only persist onion messages for relevant + * peers. */ -void LockableScore_free(struct LDKLockableScore this_ptr); +MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new_with_offline_peer_interception(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKNodeIdLookUp node_id_lookup, struct LDKMessageRouter message_router, struct LDKOffersMessageHandler offers_handler, struct LDKAsyncPaymentsMessageHandler async_payments_handler, struct LDKDNSResolverMessageHandler dns_resolver, struct LDKCustomOnionMessageHandler custom_handler); /** - * Calls the free function if one is set + * Sends an [`OnionMessage`] based on its [`MessageSendInstructions`]. */ -void WriteableScore_free(struct LDKWriteableScore this_ptr); +MUST_USE_RES struct LDKCResult_SendSuccessSendErrorZ OnionMessenger_send_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessageContents contents, struct LDKMessageSendInstructions instructions); /** - * Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL. + * Forwards an [`OnionMessage`] to `peer_node_id`. Useful if we initialized + * the [`OnionMessenger`] with [`Self::new_with_offline_peer_interception`] + * and want to forward a previously intercepted onion message to a peer that + * has just come online. */ -void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj); +MUST_USE_RES struct LDKCResult_NoneSendErrorZ OnionMessenger_forward_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessage message, struct LDKPublicKey peer_node_id); /** - * Constructs a new LockableScore which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is + * Handles the response to an [`OnionMessage`] based on its [`ResponseInstruction`], + * enqueueing any response for sending. + * + * This function is useful for asynchronous handling of [`OnionMessage`]s. + * Handlers have the option to return `None`, indicating that no immediate response should be + * sent. Then, they can transfer the associated [`Responder`] to another task responsible for + * generating the response asynchronously. Subsequently, when the response is prepared and + * ready for sending, that task can invoke this method to enqueue the response for delivery. */ -struct LDKLockableScore MultiThreadedLockableScore_as_LockableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_SendSuccessSendErrorZ OnionMessenger_handle_onion_message_response(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessageContents response, struct LDKResponseInstruction instructions); /** - * Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read + * Gets a [`Future`] that completes when an event is available via + * [`EventsProvider::process_pending_events`] or [`Self::process_pending_events_async`]. + * + * Note that callbacks registered on the [`Future`] MUST NOT call back into this + * [`OnionMessenger`] and should instead register actions to be taken later. + * + * [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events */ -struct LDKCVec_u8Z MultiThreadedLockableScore_write(const struct LDKMultiThreadedLockableScore *NONNULL_PTR obj); +MUST_USE_RES struct LDKFuture OnionMessenger_get_update_future(const struct LDKOnionMessenger *NONNULL_PTR this_arg); /** - * Constructs a new WriteableScore which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned WriteableScore must be freed before this_arg is + * Constructs a new EventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is */ -struct LDKWriteableScore MultiThreadedLockableScore_as_WriteableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); +struct LDKEventsProvider OnionMessenger_as_EventsProvider(const struct LDKOnionMessenger *NONNULL_PTR this_arg); /** - * Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. + * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is */ -MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new(struct LDKScore score); +struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct LDKOnionMessenger *NONNULL_PTR this_arg); /** - * Frees any resources used by the MultiThreadedScoreLockRead, if is_owned is set and inner is non-NULL. + * Calls the free function if one is set */ -void MultiThreadedScoreLockRead_free(struct LDKMultiThreadedScoreLockRead this_obj); +void OffersMessageHandler_free(struct LDKOffersMessageHandler this_ptr); /** - * Frees any resources used by the MultiThreadedScoreLockWrite, if is_owned is set and inner is non-NULL. + * Frees any resources used by the OffersMessage */ -void MultiThreadedScoreLockWrite_free(struct LDKMultiThreadedScoreLockWrite this_obj); +void OffersMessage_free(struct LDKOffersMessage this_ptr); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * Creates a copy of the OffersMessage */ -struct LDKScoreLookUp MultiThreadedScoreLockRead_as_ScoreLookUp(const struct LDKMultiThreadedScoreLockRead *NONNULL_PTR this_arg); +struct LDKOffersMessage OffersMessage_clone(const struct LDKOffersMessage *NONNULL_PTR orig); /** - * Serialize the MultiThreadedScoreLockWrite object into a byte array which can be read by MultiThreadedScoreLockWrite_read + * Utility method to constructs a new InvoiceRequest-variant OffersMessage */ -struct LDKCVec_u8Z MultiThreadedScoreLockWrite_write(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR obj); +struct LDKOffersMessage OffersMessage_invoice_request(struct LDKInvoiceRequest a); /** - * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is + * Utility method to constructs a new Invoice-variant OffersMessage */ -struct LDKScoreUpdate MultiThreadedScoreLockWrite_as_ScoreUpdate(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR this_arg); +struct LDKOffersMessage OffersMessage_invoice(struct LDKBolt12Invoice a); /** - * Frees any resources used by the ChannelUsage, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new InvoiceError-variant OffersMessage */ -void ChannelUsage_free(struct LDKChannelUsage this_obj); +struct LDKOffersMessage OffersMessage_invoice_error(struct LDKInvoiceError a); /** - * The amount to send through the channel, denominated in millisatoshis. + * Returns whether `tlv_type` corresponds to a TLV record for Offers. */ -uint64_t ChannelUsage_get_amount_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +MUST_USE_RES bool OffersMessage_is_known_type(uint64_t tlv_type); /** - * The amount to send through the channel, denominated in millisatoshis. + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -void ChannelUsage_set_amount_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); +struct LDKOnionMessageContents OffersMessage_as_OnionMessageContents(const struct LDKOffersMessage *NONNULL_PTR this_arg); /** - * Total amount, denominated in millisatoshis, already allocated to send through the channel - * as part of a multi-path payment. + * Serialize the OffersMessage object into a byte array which can be read by OffersMessage_read */ -uint64_t ChannelUsage_get_inflight_htlc_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z OffersMessage_write(const struct LDKOffersMessage *NONNULL_PTR obj); /** - * Total amount, denominated in millisatoshis, already allocated to send through the channel - * as part of a multi-path payment. + * Read a OffersMessage from a byte array, created by OffersMessage_write */ -void ChannelUsage_set_inflight_htlc_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_OffersMessageDecodeErrorZ OffersMessage_read(struct LDKu8slice ser, uint64_t arg_a, const struct LDKLogger *NONNULL_PTR arg_b); /** - * The effective capacity of the channel. + * Frees any resources used by the Packet, if is_owned is set and inner is non-NULL. */ -struct LDKEffectiveCapacity ChannelUsage_get_effective_capacity(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +void Packet_free(struct LDKPacket this_obj); /** - * The effective capacity of the channel. + * Bolt 04 version number */ -void ChannelUsage_set_effective_capacity(struct LDKChannelUsage *NONNULL_PTR this_ptr, struct LDKEffectiveCapacity val); +uint8_t Packet_get_version(const struct LDKPacket *NONNULL_PTR this_ptr); /** - * Constructs a new ChannelUsage given each field + * Bolt 04 version number */ -MUST_USE_RES struct LDKChannelUsage ChannelUsage_new(uint64_t amount_msat_arg, uint64_t inflight_htlc_msat_arg, struct LDKEffectiveCapacity effective_capacity_arg); +void Packet_set_version(struct LDKPacket *NONNULL_PTR this_ptr, uint8_t val); /** - * Creates a copy of the ChannelUsage + * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data */ -struct LDKChannelUsage ChannelUsage_clone(const struct LDKChannelUsage *NONNULL_PTR orig); +struct LDKPublicKey Packet_get_public_key(const struct LDKPacket *NONNULL_PTR this_ptr); /** - * Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. + * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data */ -void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj); +void Packet_set_public_key(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a copy of the FixedPenaltyScorer + * Encrypted payload for the next hop + * + * Returns a copy of the field. */ -struct LDKFixedPenaltyScorer FixedPenaltyScorer_clone(const struct LDKFixedPenaltyScorer *NONNULL_PTR orig); +struct LDKCVec_u8Z Packet_get_hop_data(const struct LDKPacket *NONNULL_PTR this_ptr); /** - * Creates a new scorer using `penalty_msat`. + * Encrypted payload for the next hop */ -MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64_t penalty_msat); +void Packet_set_hop_data(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * HMAC to verify the integrity of hop_data */ -struct LDKScoreLookUp FixedPenaltyScorer_as_ScoreLookUp(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); +const uint8_t (*Packet_get_hmac(const struct LDKPacket *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is + * HMAC to verify the integrity of hop_data */ -struct LDKScoreUpdate FixedPenaltyScorer_as_ScoreUpdate(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); +void Packet_set_hmac(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read + * Constructs a new Packet given each field */ -struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); +MUST_USE_RES struct LDKPacket Packet_new(uint8_t version_arg, struct LDKPublicKey public_key_arg, struct LDKCVec_u8Z hop_data_arg, struct LDKThirtyTwoBytes hmac_arg); /** - * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write + * Creates a copy of the Packet */ -struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser, uint64_t arg); +struct LDKPacket Packet_clone(const struct LDKPacket *NONNULL_PTR orig); /** - * Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the Packet. */ -void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj); +uint64_t Packet_hash(const struct LDKPacket *NONNULL_PTR o); /** - * Frees any resources used by the ProbabilisticScoringFeeParameters, if is_owned is set and inner is non-NULL. + * Checks if two Packets contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ProbabilisticScoringFeeParameters_free(struct LDKProbabilisticScoringFeeParameters this_obj); +bool Packet_eq(const struct LDKPacket *NONNULL_PTR a, const struct LDKPacket *NONNULL_PTR b); /** - * A fixed penalty in msats to apply to each channel. - * - * In testing, a value of roughly 1/10th of [`historical_liquidity_penalty_multiplier_msat`] - * (implying scaling all estimated probabilities down by a factor of ~79%) resulted in the - * most accurate total success probabilities. - * - * Default value: 1,024 msat (i.e. we're willing to pay 1 sat to avoid each additional hop). - * - * [`historical_liquidity_penalty_multiplier_msat`]: Self::historical_liquidity_penalty_multiplier_msat + * Serialize the Packet object into a byte array which can be read by Packet_read */ -uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Packet_write(const struct LDKPacket *NONNULL_PTR obj); /** - * A fixed penalty in msats to apply to each channel. - * - * In testing, a value of roughly 1/10th of [`historical_liquidity_penalty_multiplier_msat`] - * (implying scaling all estimated probabilities down by a factor of ~79%) resulted in the - * most accurate total success probabilities. - * - * Default value: 1,024 msat (i.e. we're willing to pay 1 sat to avoid each additional hop). - * - * [`historical_liquidity_penalty_multiplier_msat`]: Self::historical_liquidity_penalty_multiplier_msat + * Frees any resources used by the ParsedOnionMessageContents */ -void ProbabilisticScoringFeeParameters_set_base_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +void ParsedOnionMessageContents_free(struct LDKParsedOnionMessageContents this_ptr); /** - * A multiplier used with the payment amount to calculate a fixed penalty applied to each - * channel, in excess of the [`base_penalty_msat`]. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^30`ths of the payment amount. - * - * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` - * - * In testing, a value of roughly ~100x (1/10th * 2^10) of - * [`historical_liquidity_penalty_amount_multiplier_msat`] (implying scaling all estimated - * probabilities down by a factor of ~79%) resulted in the most accurate total success - * probabilities. - * - * Default value: 131,072 msat (i.e. we're willing to pay 0.125bps to avoid each additional - * hop). - * - * [`base_penalty_msat`]: Self::base_penalty_msat - * [`historical_liquidity_penalty_amount_multiplier_msat`]: Self::historical_liquidity_penalty_amount_multiplier_msat + * Creates a copy of the ParsedOnionMessageContents */ -uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKParsedOnionMessageContents ParsedOnionMessageContents_clone(const struct LDKParsedOnionMessageContents *NONNULL_PTR orig); /** - * A multiplier used with the payment amount to calculate a fixed penalty applied to each - * channel, in excess of the [`base_penalty_msat`]. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^30`ths of the payment amount. - * - * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` - * - * In testing, a value of roughly ~100x (1/10th * 2^10) of - * [`historical_liquidity_penalty_amount_multiplier_msat`] (implying scaling all estimated - * probabilities down by a factor of ~79%) resulted in the most accurate total success - * probabilities. - * - * Default value: 131,072 msat (i.e. we're willing to pay 0.125bps to avoid each additional - * hop). - * - * [`base_penalty_msat`]: Self::base_penalty_msat - * [`historical_liquidity_penalty_amount_multiplier_msat`]: Self::historical_liquidity_penalty_amount_multiplier_msat + * Utility method to constructs a new Offers-variant ParsedOnionMessageContents */ -void ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKParsedOnionMessageContents ParsedOnionMessageContents_offers(struct LDKOffersMessage a); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for a payment, as determined by our latest estimates of the channel's - * liquidity, to determine the liquidity penalty. - * - * The penalty is based in part on the knowledge learned from prior successful and unsuccessful - * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The - * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to - * lower bounding the success probability to `0.01`) when the amount falls within the - * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will - * result in a `u64::max_value` penalty, however. - * - * `-log10(success_probability) * liquidity_penalty_multiplier_msat` - * - * In testing, this scoring model performs much worse than the historical scoring model - * configured with the [`historical_liquidity_penalty_multiplier_msat`] and thus is disabled - * by default. - * - * Default value: 0 msat - * - * [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life - * [`historical_liquidity_penalty_multiplier_msat`]: Self::historical_liquidity_penalty_multiplier_msat + * Utility method to constructs a new DNSResolver-variant ParsedOnionMessageContents */ -uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKParsedOnionMessageContents ParsedOnionMessageContents_dnsresolver(struct LDKDNSResolverMessage a); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for a payment, as determined by our latest estimates of the channel's - * liquidity, to determine the liquidity penalty. - * - * The penalty is based in part on the knowledge learned from prior successful and unsuccessful - * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The - * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to - * lower bounding the success probability to `0.01`) when the amount falls within the - * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will - * result in a `u64::max_value` penalty, however. - * - * `-log10(success_probability) * liquidity_penalty_multiplier_msat` - * - * In testing, this scoring model performs much worse than the historical scoring model - * configured with the [`historical_liquidity_penalty_multiplier_msat`] and thus is disabled - * by default. - * - * Default value: 0 msat - * - * [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life - * [`historical_liquidity_penalty_multiplier_msat`]: Self::historical_liquidity_penalty_multiplier_msat + * Utility method to constructs a new Custom-variant ParsedOnionMessageContents */ -void ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKParsedOnionMessageContents ParsedOnionMessageContents_custom(struct LDKOnionMessageContents a); /** - * A multiplier used in conjunction with the payment amount and the negative `log10` of the - * channel's success probability for the total amount flowing over a channel, as determined by - * our latest estimates of the channel's liquidity, to determine the amount penalty. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the - * success probability. - * - * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` - * - * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of - * the amount will result in a penalty of the multiplier. And, as the success probability - * decreases, the negative `log10` weighting will increase dramatically. For higher success - * probabilities, the multiplier will have a decreasing effect as the negative `log10` will - * fall below `1`. - * - * In testing, this scoring model performs much worse than the historical scoring model - * configured with the [`historical_liquidity_penalty_amount_multiplier_msat`] and thus is - * disabled by default. - * - * Default value: 0 msat - * - * [`historical_liquidity_penalty_amount_multiplier_msat`]: Self::historical_liquidity_penalty_amount_multiplier_msat + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKOnionMessageContents ParsedOnionMessageContents_as_OnionMessageContents(const struct LDKParsedOnionMessageContents *NONNULL_PTR this_arg); /** - * A multiplier used in conjunction with the payment amount and the negative `log10` of the - * channel's success probability for the total amount flowing over a channel, as determined by - * our latest estimates of the channel's liquidity, to determine the amount penalty. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the - * success probability. - * - * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` - * - * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of - * the amount will result in a penalty of the multiplier. And, as the success probability - * decreases, the negative `log10` weighting will increase dramatically. For higher success - * probabilities, the multiplier will have a decreasing effect as the negative `log10` will - * fall below `1`. - * - * In testing, this scoring model performs much worse than the historical scoring model - * configured with the [`historical_liquidity_penalty_amount_multiplier_msat`] and thus is - * disabled by default. - * - * Default value: 0 msat - * - * [`historical_liquidity_penalty_amount_multiplier_msat`]: Self::historical_liquidity_penalty_amount_multiplier_msat + * Serialize the ParsedOnionMessageContents object into a byte array which can be read by ParsedOnionMessageContents_read */ -void ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z ParsedOnionMessageContents_write(const struct LDKParsedOnionMessageContents *NONNULL_PTR obj); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for the payment, as determined based on the history of our estimates of the - * channel's available liquidity, to determine a penalty. - * - * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using - * only our latest estimate for the current liquidity available in the channel, it estimates - * success probability based on the estimated liquidity available in the channel through - * history. Specifically, every time we update our liquidity bounds on a given channel, we - * track which of several buckets those bounds fall into, exponentially decaying the - * probability of each bucket as new samples are added. - * - * Default value: 10,000 msat (i.e. willing to pay 1 sat to avoid an 80% probability channel, - * or 6 sats to avoid a 25% probability channel). - * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * Creates a copy of a OnionMessageContents */ -uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKOnionMessageContents OnionMessageContents_clone(const struct LDKOnionMessageContents *NONNULL_PTR orig); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for the payment, as determined based on the history of our estimates of the - * channel's available liquidity, to determine a penalty. - * - * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using - * only our latest estimate for the current liquidity available in the channel, it estimates - * success probability based on the estimated liquidity available in the channel through - * history. Specifically, every time we update our liquidity bounds on a given channel, we - * track which of several buckets those bounds fall into, exponentially decaying the - * probability of each bucket as new samples are added. - * - * Default value: 10,000 msat (i.e. willing to pay 1 sat to avoid an 80% probability channel, - * or 6 sats to avoid a 25% probability channel). - * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * Calls the free function if one is set */ -void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +void OnionMessageContents_free(struct LDKOnionMessageContents this_ptr); /** - * A multiplier used in conjunction with the payment amount and the negative `log10` of the - * channel's success probability for the total amount flowing over a channel, as determined - * based on the history of our estimates of the channel's available liquidity, to determine a - * penalty. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost for - * large payments. The penalty is computed as the product of this multiplier and `2^20`ths - * of the payment amount, weighted by the negative `log10` of the success probability. - * - * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead - * of using only our latest estimate for the current liquidity available in the channel, it - * estimates success probability based on the estimated liquidity available in the channel - * through history. Specifically, every time we update our liquidity bounds on a given - * channel, we track which of several buckets those bounds fall into, exponentially decaying - * the probability of each bucket as new samples are added. - * - * Default value: 1,250 msat (i.e. willing to pay about 0.125 bps per hop to avoid 78% - * probability channels, or 0.5bps to avoid a 38% probability - * channel). - * - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * Frees any resources used by the IntroductionNode */ -uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +void IntroductionNode_free(struct LDKIntroductionNode this_ptr); /** - * A multiplier used in conjunction with the payment amount and the negative `log10` of the - * channel's success probability for the total amount flowing over a channel, as determined - * based on the history of our estimates of the channel's available liquidity, to determine a - * penalty. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost for - * large payments. The penalty is computed as the product of this multiplier and `2^20`ths - * of the payment amount, weighted by the negative `log10` of the success probability. - * - * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead - * of using only our latest estimate for the current liquidity available in the channel, it - * estimates success probability based on the estimated liquidity available in the channel - * through history. Specifically, every time we update our liquidity bounds on a given - * channel, we track which of several buckets those bounds fall into, exponentially decaying - * the probability of each bucket as new samples are added. - * - * Default value: 1,250 msat (i.e. willing to pay about 0.125 bps per hop to avoid 78% - * probability channels, or 0.5bps to avoid a 38% probability - * channel). - * - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * Creates a copy of the IntroductionNode */ -void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKIntroductionNode IntroductionNode_clone(const struct LDKIntroductionNode *NONNULL_PTR orig); /** - * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the - * channel's capacity, (ie. htlc_maximum_msat >= 0.5 * channel_capacity) which makes us - * prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially - * as this makes balance discovery attacks harder to execute, thereby creating an incentive - * to restrict `htlc_maximum_msat` and improve privacy. - * - * Default value: 250 msat + * Utility method to constructs a new NodeId-variant IntroductionNode */ -uint64_t ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKIntroductionNode IntroductionNode_node_id(struct LDKPublicKey a); /** - * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the - * channel's capacity, (ie. htlc_maximum_msat >= 0.5 * channel_capacity) which makes us - * prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially - * as this makes balance discovery attacks harder to execute, thereby creating an incentive - * to restrict `htlc_maximum_msat` and improve privacy. - * - * Default value: 250 msat + * Utility method to constructs a new DirectedShortChannelId-variant IntroductionNode */ -void ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKIntroductionNode IntroductionNode_directed_short_channel_id(enum LDKDirection a, uint64_t b); /** - * This penalty is applied when the total amount flowing over a channel exceeds our current - * estimate of the channel's available liquidity. The total amount is the amount of the - * current HTLC plus any HTLCs which we've sent over the same channel. - * - * Note that in this case all other penalties, including the - * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based - * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if - * applicable, are still included in the overall penalty. - * - * If you wish to avoid creating paths with such channels entirely, setting this to a value of - * `u64::max_value()` will guarantee that. - * - * Default value: 1_0000_0000_000 msat (1 Bitcoin) - * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat - * [`base_penalty_msat`]: Self::base_penalty_msat - * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat + * Generates a non-cryptographic 64-bit hash of the IntroductionNode. */ -uint64_t ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +uint64_t IntroductionNode_hash(const struct LDKIntroductionNode *NONNULL_PTR o); /** - * This penalty is applied when the total amount flowing over a channel exceeds our current - * estimate of the channel's available liquidity. The total amount is the amount of the - * current HTLC plus any HTLCs which we've sent over the same channel. - * - * Note that in this case all other penalties, including the - * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based - * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if - * applicable, are still included in the overall penalty. - * - * If you wish to avoid creating paths with such channels entirely, setting this to a value of - * `u64::max_value()` will guarantee that. - * - * Default value: 1_0000_0000_000 msat (1 Bitcoin) - * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat - * [`base_penalty_msat`]: Self::base_penalty_msat - * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat + * Checks if two IntroductionNodes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +bool IntroductionNode_eq(const struct LDKIntroductionNode *NONNULL_PTR a, const struct LDKIntroductionNode *NONNULL_PTR b); /** - * In order to calculate most of the scores above, we must first convert a lower and upper - * bound on the available liquidity in a channel into the probability that we think a payment - * will succeed. That probability is derived from a Probability Density Function for where we - * think the liquidity in a channel likely lies, given such bounds. - * - * If this flag is set, that PDF is simply a constant - we assume that the actual available - * liquidity in a channel is just as likely to be at any point between our lower and upper - * bounds. - * - * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an - * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This - * matches experimental results - most routing nodes do not aggressively rebalance their - * channels and flows in the network are often unbalanced, leaving liquidity usually - * unavailable. - * - * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number - * of floating-point multiplications in the hottest routing code, which may lead to routing - * performance degradation on some machines. - * - * Default value: false + * Creates a copy of the Direction + */ +enum LDKDirection Direction_clone(const enum LDKDirection *NONNULL_PTR orig); + +/** + * Utility method to constructs a new NodeOne-variant Direction */ -bool ProbabilisticScoringFeeParameters_get_linear_success_probability(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +enum LDKDirection Direction_node_one(void); /** - * In order to calculate most of the scores above, we must first convert a lower and upper - * bound on the available liquidity in a channel into the probability that we think a payment - * will succeed. That probability is derived from a Probability Density Function for where we - * think the liquidity in a channel likely lies, given such bounds. - * - * If this flag is set, that PDF is simply a constant - we assume that the actual available - * liquidity in a channel is just as likely to be at any point between our lower and upper - * bounds. - * - * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an - * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This - * matches experimental results - most routing nodes do not aggressively rebalance their - * channels and flows in the network are often unbalanced, leaving liquidity usually - * unavailable. - * - * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number - * of floating-point multiplications in the hottest routing code, which may lead to routing - * performance degradation on some machines. - * - * Default value: false + * Utility method to constructs a new NodeTwo-variant Direction */ -void ProbabilisticScoringFeeParameters_set_linear_success_probability(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, bool val); +enum LDKDirection Direction_node_two(void); /** - * Creates a copy of the ProbabilisticScoringFeeParameters + * Generates a non-cryptographic 64-bit hash of the Direction. */ -struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_clone(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR orig); +uint64_t Direction_hash(const enum LDKDirection *NONNULL_PTR o); /** - * Creates a "default" ProbabilisticScoringFeeParameters. See struct and individual field documentaiton for details on which values are used. + * Checks if two Directions contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_default(void); +bool Direction_eq(const enum LDKDirection *NONNULL_PTR a, const enum LDKDirection *NONNULL_PTR b); /** - * Marks the node with the given `node_id` as banned, - * i.e it will be avoided during path finding. + * Calls the free function if one is set */ -void ProbabilisticScoringFeeParameters_add_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +void NodeIdLookUp_free(struct LDKNodeIdLookUp this_ptr); /** - * Marks all nodes in the given list as banned, i.e., - * they will be avoided during path finding. + * Frees any resources used by the EmptyNodeIdLookUp, if is_owned is set and inner is non-NULL. */ -void ProbabilisticScoringFeeParameters_add_banned_from_list(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, struct LDKCVec_NodeIdZ node_ids); +void EmptyNodeIdLookUp_free(struct LDKEmptyNodeIdLookUp this_obj); /** - * Removes the node with the given `node_id` from the list of nodes to avoid. + * Constructs a new EmptyNodeIdLookUp given each field */ -void ProbabilisticScoringFeeParameters_remove_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +MUST_USE_RES struct LDKEmptyNodeIdLookUp EmptyNodeIdLookUp_new(void); /** - * Sets a manual penalty for the given node. + * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is */ -void ProbabilisticScoringFeeParameters_set_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id, uint64_t penalty); +struct LDKNodeIdLookUp EmptyNodeIdLookUp_as_NodeIdLookUp(const struct LDKEmptyNodeIdLookUp *NONNULL_PTR this_arg); /** - * Removes the node with the given `node_id` from the list of manual penalties. + * Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL. */ -void ProbabilisticScoringFeeParameters_remove_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +void BlindedHop_free(struct LDKBlindedHop this_obj); /** - * Clears the list of manual penalties that are applied during path finding. + * The blinded node id of this hop in a blinded path. */ -void ProbabilisticScoringFeeParameters_clear_manual_penalties(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg); +struct LDKPublicKey BlindedHop_get_blinded_node_id(const struct LDKBlindedHop *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ProbabilisticScoringDecayParameters, if is_owned is set and inner is non-NULL. + * The blinded node id of this hop in a blinded path. */ -void ProbabilisticScoringDecayParameters_free(struct LDKProbabilisticScoringDecayParameters this_obj); +void BlindedHop_set_blinded_node_id(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * If we aren't learning any new datapoints for a channel, the historical liquidity bounds - * tracking can simply live on with increasingly stale data. Instead, when a channel has not - * seen a liquidity estimate update for this amount of time, the historical datapoints are - * decayed by half. - * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] - * - * Note that after 16 or more half lives all historical data will be completely gone. - * - * Default value: 14 days + * The encrypted payload intended for this hop in a blinded path. * - * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities + * Returns a copy of the field. */ -uint64_t ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z BlindedHop_get_encrypted_payload(const struct LDKBlindedHop *NONNULL_PTR this_ptr); /** - * If we aren't learning any new datapoints for a channel, the historical liquidity bounds - * tracking can simply live on with increasingly stale data. Instead, when a channel has not - * seen a liquidity estimate update for this amount of time, the historical datapoints are - * decayed by half. - * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] - * - * Note that after 16 or more half lives all historical data will be completely gone. - * - * Default value: 14 days - * - * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities + * The encrypted payload intended for this hop in a blinded path. */ -void ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); +void BlindedHop_set_encrypted_payload(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, - * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on - * the available liquidity is halved and the upper-bound moves half-way to the channel's total - * capacity. - * - * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, - * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] - * struct documentation for more info on the way the liquidity bounds are used. - * - * For example, if the channel's capacity is 1 million sats, and the current upper and lower - * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper - * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. - * - * Default value: 30 minutes - * - * # Note - * - * When not built with the `std` feature, time will never elapse. Therefore, the channel - * liquidity knowledge will never decay except when the bounds cross. + * Constructs a new BlindedHop given each field */ -uint64_t ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKBlindedHop BlindedHop_new(struct LDKPublicKey blinded_node_id_arg, struct LDKCVec_u8Z encrypted_payload_arg); /** - * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, - * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on - * the available liquidity is halved and the upper-bound moves half-way to the channel's total - * capacity. - * - * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, - * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] - * struct documentation for more info on the way the liquidity bounds are used. - * - * For example, if the channel's capacity is 1 million sats, and the current upper and lower - * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper - * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. - * - * Default value: 30 minutes - * - * # Note - * - * When not built with the `std` feature, time will never elapse. Therefore, the channel - * liquidity knowledge will never decay except when the bounds cross. + * Creates a copy of the BlindedHop */ -void ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKBlindedHop BlindedHop_clone(const struct LDKBlindedHop *NONNULL_PTR orig); /** - * Constructs a new ProbabilisticScoringDecayParameters given each field + * Generates a non-cryptographic 64-bit hash of the BlindedHop. */ -MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_new(uint64_t historical_no_updates_half_life_arg, uint64_t liquidity_offset_half_life_arg); +uint64_t BlindedHop_hash(const struct LDKBlindedHop *NONNULL_PTR o); /** - * Creates a copy of the ProbabilisticScoringDecayParameters + * Checks if two BlindedHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_clone(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR orig); +bool BlindedHop_eq(const struct LDKBlindedHop *NONNULL_PTR a, const struct LDKBlindedHop *NONNULL_PTR b); /** - * Creates a "default" ProbabilisticScoringDecayParameters. See struct and individual field documentaiton for details on which values are used. + * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read */ -MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_default(void); +struct LDKCVec_u8Z BlindedHop_write(const struct LDKBlindedHop *NONNULL_PTR obj); /** - * Creates a new scorer using the given scoring parameters for sending payments from a node - * through a network graph. + * Read a BlindedHop from a byte array, created by BlindedHop_write */ -MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringDecayParameters decay_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); +struct LDKCResult_BlindedHopDecodeErrorZ BlindedHop_read(struct LDKu8slice ser); /** - * Dump the contents of this scorer into the configured logger. - * - * Note that this writes roughly one line per channel for which we have a liquidity estimate, - * which may be a substantial amount of log output. + * Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. */ -void ProbabilisticScorer_debug_log_liquidity_stats(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +void BlindedPayInfo_free(struct LDKBlindedPayInfo this_obj); /** - * Query the estimated minimum and maximum liquidity available for sending a payment over the - * channel with `scid` towards the given `target` node. + * Base fee charged (in millisatoshi) for the entire blinded path. */ -MUST_USE_RES struct LDKCOption_C2Tuple_u64u64ZZ ProbabilisticScorer_estimated_channel_liquidity_range(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); +uint32_t BlindedPayInfo_get_fee_base_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Query the historical estimated minimum and maximum liquidity available for sending a - * payment over the channel with `scid` towards the given `target` node. - * - * Returns two sets of 32 buckets. The first set describes the lower-bound liquidity history, - * the second set describes the upper-bound liquidity history. Each bucket describes the - * relative frequency at which we've seen a liquidity bound in the bucket's range relative to - * the channel's total capacity, on an arbitrary scale. Because the values are slowly decayed, - * more recent data points are weighted more heavily than older datapoints. - * - * Note that the range of each bucket varies by its location to provide more granular results - * at the edges of a channel's capacity, where it is more likely to sit. - * - * When scoring, the estimated probability that an upper-/lower-bound lies in a given bucket - * is calculated by dividing that bucket's value with the total value of all buckets. - * - * For example, using a lower bucket count for illustrative purposes, a value of - * `[0, 0, 0, ..., 0, 32]` indicates that we believe the probability of a bound being very - * close to the channel's capacity to be 100%, and have never (recently) seen it in any other - * bucket. A value of `[31, 0, 0, ..., 0, 0, 32]` indicates we've seen the bound being both - * in the top and bottom bucket, and roughly with similar (recent) frequency. - * - * Because the datapoints are decayed slowly over time, values will eventually return to - * `Some(([0; 32], [0; 32]))` or `None` if no data remains for a channel. - * - * In order to fetch a single success probability from the buckets provided here, as used in - * the scoring model, see [`Self::historical_estimated_payment_success_probability`]. + * Base fee charged (in millisatoshi) for the entire blinded path. */ -MUST_USE_RES struct LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); +void BlindedPayInfo_set_fee_base_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Query the probability of payment success sending the given `amount_msat` over the channel - * with `scid` towards the given `target` node, based on the historical estimated liquidity - * bounds. - * - * Returns `None` if: - * - the given channel is not in the network graph, the provided `target` is not a party to - * the channel, or we don't have forwarding parameters for either direction in the channel. - * - `allow_fallback_estimation` is *not* set and there is no (or insufficient) historical - * data for the given channel. - * - * These are the same bounds as returned by - * [`Self::historical_estimated_channel_liquidity_probabilities`] (but not those returned by - * [`Self::estimated_channel_liquidity_range`]). + * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path + * (i.e., 10,000 is 1%). */ -MUST_USE_RES struct LDKCOption_f64Z ProbabilisticScorer_historical_estimated_payment_success_probability(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target, uint64_t amount_msat, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR params, bool allow_fallback_estimation); +uint32_t BlindedPayInfo_get_fee_proportional_millionths(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Query the probability of payment success sending the given `amount_msat` over the channel - * with `scid` towards the given `target` node, based on the live estimated liquidity bounds. - * - * This will return `Some` for any channel which is present in the [`NetworkGraph`], including - * if we have no bound information beside the channel's capacity. + * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path + * (i.e., 10,000 is 1%). */ -MUST_USE_RES struct LDKCOption_f64Z ProbabilisticScorer_live_estimated_payment_success_probability(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target, uint64_t amount_msat, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR params); +void BlindedPayInfo_set_fee_proportional_millionths(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded + * path. */ -struct LDKScoreLookUp ProbabilisticScorer_as_ScoreLookUp(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +uint16_t BlindedPayInfo_get_cltv_expiry_delta(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded + * path. */ -struct LDKScoreUpdate ProbabilisticScorer_as_ScoreUpdate(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +void BlindedPayInfo_set_cltv_expiry_delta(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint16_t val); /** - * Constructs a new Score which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is + * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +uint64_t BlindedPayInfo_get_htlc_minimum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read + * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj); +void BlindedPayInfo_set_htlc_minimum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write + * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringDecayParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c); +uint64_t BlindedPayInfo_get_htlc_maximum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); +void BlindedPayInfo_set_htlc_maximum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * The outpoint which is spendable. + * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an + * onion payload. */ -struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKBlindedHopFeatures BlindedPayInfo_get_features(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * The outpoint which is spendable. + * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an + * onion payload. */ -void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void BlindedPayInfo_set_features(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); /** - * Per commitment point to derive the delayed payment key by key holder. + * Constructs a new BlindedPayInfo given each field */ -struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKBlindedPayInfo BlindedPayInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKBlindedHopFeatures features_arg); /** - * Per commitment point to derive the delayed payment key by key holder. + * Creates a copy of the BlindedPayInfo */ -void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKBlindedPayInfo BlindedPayInfo_clone(const struct LDKBlindedPayInfo *NONNULL_PTR orig); /** - * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in - * the witness_script. + * Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. */ -uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +uint64_t BlindedPayInfo_hash(const struct LDKBlindedPayInfo *NONNULL_PTR o); /** - * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in - * the witness_script. + * Checks if two BlindedPayInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); +bool BlindedPayInfo_eq(const struct LDKBlindedPayInfo *NONNULL_PTR a, const struct LDKBlindedPayInfo *NONNULL_PTR b); /** - * The output which is referenced by the given outpoint. + * Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read */ -struct LDKTxOut DelayedPaymentOutputDescriptor_get_output(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z BlindedPayInfo_write(const struct LDKBlindedPayInfo *NONNULL_PTR obj); /** - * The output which is referenced by the given outpoint. + * Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write */ -void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +struct LDKCResult_BlindedPayInfoDecodeErrorZ BlindedPayInfo_read(struct LDKu8slice ser); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * Frees any resources used by the BlindedPaymentPath, if is_owned is set and inner is non-NULL. */ -struct LDKRevocationKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void BlindedPaymentPath_free(struct LDKBlindedPaymentPath this_obj); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * The [`BlindedPayInfo`] used to pay this blinded path. */ -void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKRevocationKey val); +struct LDKBlindedPayInfo BlindedPaymentPath_get_payinfo(const struct LDKBlindedPaymentPath *NONNULL_PTR this_ptr); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * The [`BlindedPayInfo`] used to pay this blinded path. */ -const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +void BlindedPaymentPath_set_payinfo(struct LDKBlindedPaymentPath *NONNULL_PTR this_ptr, struct LDKBlindedPayInfo val); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * Creates a copy of the BlindedPaymentPath */ -void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKBlindedPaymentPath BlindedPaymentPath_clone(const struct LDKBlindedPaymentPath *NONNULL_PTR orig); /** - * The value of the channel which this output originated from, possibly indirectly. + * Generates a non-cryptographic 64-bit hash of the BlindedPaymentPath. */ -uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +uint64_t BlindedPaymentPath_hash(const struct LDKBlindedPaymentPath *NONNULL_PTR o); /** - * The value of the channel which this output originated from, possibly indirectly. + * Checks if two BlindedPaymentPaths contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +bool BlindedPaymentPath_eq(const struct LDKBlindedPaymentPath *NONNULL_PTR a, const struct LDKBlindedPaymentPath *NONNULL_PTR b); /** - * The channel public keys and other parameters needed to generate a spending transaction or - * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. + * Create a one-hop blinded path for a payment. + */ +MUST_USE_RES struct LDKCResult_BlindedPaymentPathNoneZ BlindedPaymentPath_one_hop(struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, uint16_t min_final_cltv_expiry_delta, struct LDKEntropySource entropy_source); + +/** + * Create a blinded path for a payment, to be forwarded along `intermediate_nodes`. * - * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. + * Errors if: + * * a provided node id is invalid + * * [`BlindedPayInfo`] calculation results in an integer overflow + * * any unknown features are required in the provided [`ForwardTlvs`] + */ +MUST_USE_RES struct LDKCResult_BlindedPaymentPathNoneZ BlindedPaymentPath_new(struct LDKCVec_PaymentForwardNodeZ intermediate_nodes, struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, uint64_t htlc_maximum_msat, uint16_t min_final_cltv_expiry_delta, struct LDKEntropySource entropy_source); + +/** + * Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., + * it is found in the network graph). * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKChannelTransactionParameters DelayedPaymentOutputDescriptor_get_channel_transaction_parameters(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKNodeId BlindedPaymentPath_public_introduction_node_id(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); /** - * The channel public keys and other parameters needed to generate a spending transaction or - * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. - * - * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. + * The [`IntroductionNode`] of the blinded path. + */ +MUST_USE_RES struct LDKIntroductionNode BlindedPaymentPath_introduction_node(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); + +/** + * Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the payment. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`encrypted_payload`]: BlindedHop::encrypted_payload */ -void DelayedPaymentOutputDescriptor_set_channel_transaction_parameters(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); +MUST_USE_RES struct LDKPublicKey BlindedPaymentPath_blinding_point(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); /** - * Constructs a new DelayedPaymentOutputDescriptor given each field + * The [`BlindedHop`]s within the blinded path. + */ +MUST_USE_RES struct LDKCVec_BlindedHopZ BlindedPaymentPath_blinded_hops(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); + +/** + * Advance the blinded onion payment path by one hop, making the second hop into the new + * introduction node. * - * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Will only modify `self` when returning `Ok`. */ -MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKRevocationKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg, struct LDKChannelTransactionParameters channel_transaction_parameters_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedPaymentPath_advance_path_by_one(struct LDKBlindedPaymentPath *NONNULL_PTR this_arg, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup); /** - * Creates a copy of the DelayedPaymentOutputDescriptor + * Frees any resources used by the PaymentForwardNode, if is_owned is set and inner is non-NULL. */ -struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); +void PaymentForwardNode_free(struct LDKPaymentForwardNode this_obj); /** - * Generates a non-cryptographic 64-bit hash of the DelayedPaymentOutputDescriptor. + * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also + * used for [`BlindedPayInfo`] construction. */ -uint64_t DelayedPaymentOutputDescriptor_hash(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR o); +struct LDKForwardTlvs PaymentForwardNode_get_tlvs(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); /** - * Checks if two DelayedPaymentOutputDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also + * used for [`BlindedPayInfo`] construction. */ -bool DelayedPaymentOutputDescriptor_eq(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR b); +void PaymentForwardNode_set_tlvs(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, struct LDKForwardTlvs val); /** - * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read + * This node's pubkey. */ -struct LDKCVec_u8Z DelayedPaymentOutputDescriptor_write(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR obj); +struct LDKPublicKey PaymentForwardNode_get_node_id(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); /** - * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write + * This node's pubkey. */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ DelayedPaymentOutputDescriptor_read(struct LDKu8slice ser); +void PaymentForwardNode_set_node_id(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * The maximum value, in msat, that may be accepted by this node. */ -void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); +uint64_t PaymentForwardNode_get_htlc_maximum_msat(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); /** - * The outpoint which is spendable. + * The maximum value, in msat, that may be accepted by this node. */ -struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void PaymentForwardNode_set_htlc_maximum_msat(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, uint64_t val); /** - * The outpoint which is spendable. + * Constructs a new PaymentForwardNode given each field */ -void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +MUST_USE_RES struct LDKPaymentForwardNode PaymentForwardNode_new(struct LDKForwardTlvs tlvs_arg, struct LDKPublicKey node_id_arg, uint64_t htlc_maximum_msat_arg); /** - * The output which is referenced by the given outpoint. + * Creates a copy of the PaymentForwardNode */ -struct LDKTxOut StaticPaymentOutputDescriptor_get_output(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKPaymentForwardNode PaymentForwardNode_clone(const struct LDKPaymentForwardNode *NONNULL_PTR orig); /** - * The output which is referenced by the given outpoint. + * Frees any resources used by the ForwardTlvs, if is_owned is set and inner is non-NULL. */ -void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +void ForwardTlvs_free(struct LDKForwardTlvs this_obj); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * The short channel id this payment should be forwarded out over. */ -const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +uint64_t ForwardTlvs_get_short_channel_id(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * The short channel id this payment should be forwarded out over. */ -void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ForwardTlvs_set_short_channel_id(struct LDKForwardTlvs *NONNULL_PTR this_ptr, uint64_t val); /** - * The value of the channel which this transactions spends. + * Payment parameters for relaying over [`Self::short_channel_id`]. */ -uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKPaymentRelay ForwardTlvs_get_payment_relay(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * The value of the channel which this transactions spends. + * Payment parameters for relaying over [`Self::short_channel_id`]. */ -void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +void ForwardTlvs_set_payment_relay(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentRelay val); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. + * Payment constraints for relaying over [`Self::short_channel_id`]. + */ +struct LDKPaymentConstraints ForwardTlvs_get_payment_constraints(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); + +/** + * Payment constraints for relaying over [`Self::short_channel_id`]. + */ +void ForwardTlvs_set_payment_constraints(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); + +/** + * Supported and required features when relaying a payment onion containing this object's + * corresponding [`BlindedHop::encrypted_payload`]. * - * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. + * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload + */ +struct LDKBlindedHopFeatures ForwardTlvs_get_features(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); + +/** + * Supported and required features when relaying a payment onion containing this object's + * corresponding [`BlindedHop::encrypted_payload`]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload */ -struct LDKChannelTransactionParameters StaticPaymentOutputDescriptor_get_channel_transaction_parameters(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void ForwardTlvs_set_features(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. + * Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the + * [`BlindedPaymentPath::blinding_point`] of the appended blinded path. * - * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKPublicKey ForwardTlvs_get_next_blinding_override(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); + +/** + * Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the + * [`BlindedPaymentPath::blinding_point`] of the appended blinded path. * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void StaticPaymentOutputDescriptor_set_channel_transaction_parameters(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); +void ForwardTlvs_set_next_blinding_override(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new StaticPaymentOutputDescriptor given each field + * Constructs a new ForwardTlvs given each field * - * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that next_blinding_override_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg, struct LDKChannelTransactionParameters channel_transaction_parameters_arg); +MUST_USE_RES struct LDKForwardTlvs ForwardTlvs_new(uint64_t short_channel_id_arg, struct LDKPaymentRelay payment_relay_arg, struct LDKPaymentConstraints payment_constraints_arg, struct LDKBlindedHopFeatures features_arg, struct LDKPublicKey next_blinding_override_arg); + +/** + * Creates a copy of the ForwardTlvs + */ +struct LDKForwardTlvs ForwardTlvs_clone(const struct LDKForwardTlvs *NONNULL_PTR orig); + +/** + * Frees any resources used by the ReceiveTlvs, if is_owned is set and inner is non-NULL. + */ +void ReceiveTlvs_free(struct LDKReceiveTlvs this_obj); + +/** + * Creates a copy of the ReceiveTlvs + */ +struct LDKReceiveTlvs ReceiveTlvs_clone(const struct LDKReceiveTlvs *NONNULL_PTR orig); + +/** + * Returns the underlying TLVs. + */ +MUST_USE_RES struct LDKUnauthenticatedReceiveTlvs ReceiveTlvs_tlvs(const struct LDKReceiveTlvs *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the UnauthenticatedReceiveTlvs, if is_owned is set and inner is non-NULL. + */ +void UnauthenticatedReceiveTlvs_free(struct LDKUnauthenticatedReceiveTlvs this_obj); /** - * Creates a copy of the StaticPaymentOutputDescriptor + * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. */ -struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); +const uint8_t (*UnauthenticatedReceiveTlvs_get_payment_secret(const struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr))[32]; /** - * Generates a non-cryptographic 64-bit hash of the StaticPaymentOutputDescriptor. + * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. */ -uint64_t StaticPaymentOutputDescriptor_hash(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR o); +void UnauthenticatedReceiveTlvs_set_payment_secret(struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Checks if two StaticPaymentOutputDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constraints for the receiver of this payment. */ -bool StaticPaymentOutputDescriptor_eq(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR b); +struct LDKPaymentConstraints UnauthenticatedReceiveTlvs_get_payment_constraints(const struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr); /** - * Returns the `witness_script` of the spendable output. - * - * Note that this will only return `Some` for [`StaticPaymentOutputDescriptor`]s that - * originated from an anchor outputs channel, as they take the form of a P2WSH script. + * Constraints for the receiver of this payment. */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ StaticPaymentOutputDescriptor_witness_script(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); +void UnauthenticatedReceiveTlvs_set_payment_constraints(struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); /** - * The maximum length a well-formed witness spending one of these should have. - * Note: If you have the grind_signatures feature enabled, this will be at least 1 byte - * shorter. + * Context for the receiver of this payment. */ -MUST_USE_RES uint64_t StaticPaymentOutputDescriptor_max_witness_length(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); +struct LDKPaymentContext UnauthenticatedReceiveTlvs_get_payment_context(const struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr); /** - * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read + * Context for the receiver of this payment. */ -struct LDKCVec_u8Z StaticPaymentOutputDescriptor_write(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR obj); +void UnauthenticatedReceiveTlvs_set_payment_context(struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr, struct LDKPaymentContext val); /** - * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write + * Constructs a new UnauthenticatedReceiveTlvs given each field */ -struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ StaticPaymentOutputDescriptor_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKUnauthenticatedReceiveTlvs UnauthenticatedReceiveTlvs_new(struct LDKThirtyTwoBytes payment_secret_arg, struct LDKPaymentConstraints payment_constraints_arg, struct LDKPaymentContext payment_context_arg); /** - * Frees any resources used by the SpendableOutputDescriptor + * Creates a copy of the UnauthenticatedReceiveTlvs */ -void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); +struct LDKUnauthenticatedReceiveTlvs UnauthenticatedReceiveTlvs_clone(const struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR orig); /** - * Creates a copy of the SpendableOutputDescriptor + * Creates an authenticated [`ReceiveTlvs`], which includes an HMAC and the provide [`Nonce`] + * that can be use later to verify it authenticity. */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); +MUST_USE_RES struct LDKReceiveTlvs UnauthenticatedReceiveTlvs_authenticate(struct LDKUnauthenticatedReceiveTlvs this_arg, struct LDKNonce nonce, const struct LDKExpandedKey *NONNULL_PTR expanded_key); /** - * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor + * Frees any resources used by the PaymentRelay, if is_owned is set and inner is non-NULL. */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_output(struct LDKOutPoint outpoint, struct LDKTxOut output, struct LDKThirtyTwoBytes channel_keys_id); +void PaymentRelay_free(struct LDKPaymentRelay this_obj); /** - * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_output(struct LDKDelayedPaymentOutputDescriptor a); +uint16_t PaymentRelay_get_cltv_expiry_delta(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a); +void PaymentRelay_set_cltv_expiry_delta(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint16_t val); /** - * Generates a non-cryptographic 64-bit hash of the SpendableOutputDescriptor. + * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over + * this [`BlindedHop`], (i.e., 10,000 is 1%). */ -uint64_t SpendableOutputDescriptor_hash(const struct LDKSpendableOutputDescriptor *NONNULL_PTR o); +uint32_t PaymentRelay_get_fee_proportional_millionths(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); /** - * Checks if two SpendableOutputDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over + * this [`BlindedHop`], (i.e., 10,000 is 1%). */ -bool SpendableOutputDescriptor_eq(const struct LDKSpendableOutputDescriptor *NONNULL_PTR a, const struct LDKSpendableOutputDescriptor *NONNULL_PTR b); +void PaymentRelay_set_fee_proportional_millionths(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); /** - * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read + * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. */ -struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); +uint32_t PaymentRelay_get_fee_base_msat(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); /** - * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write + * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); +void PaymentRelay_set_fee_base_msat(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates an unsigned [`Psbt`] which spends the given descriptors to - * the given outputs, plus an output to the given change destination (if sufficient - * change value remains). The PSBT will have a feerate, at least, of the given value. - * - * The `locktime` argument is used to set the transaction's locktime. If `None`, the - * transaction will have a locktime of 0. It it recommended to set this to the current block - * height to avoid fee sniping, unless you have some specific reason to use a different - * locktime. - * - * Returns the PSBT and expected max transaction weight. - * - * Returns `Err(())` if the output value is greater than the input value minus required fee, - * if a descriptor was duplicated, or if an output descriptor `script_pubkey` - * does not match the one we can spend. - * - * We do not enforce that outputs meet the dust limit or that any output scripts are standard. + * Constructs a new PaymentRelay given each field */ -MUST_USE_RES struct LDKCResult_C2Tuple_CVec_u8Zu64ZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_u32Z locktime); +MUST_USE_RES struct LDKPaymentRelay PaymentRelay_new(uint16_t cltv_expiry_delta_arg, uint32_t fee_proportional_millionths_arg, uint32_t fee_base_msat_arg); /** - * Returns the outpoint of the spendable output. + * Creates a copy of the PaymentRelay */ -MUST_USE_RES struct LDKOutPoint SpendableOutputDescriptor_spendable_outpoint(const struct LDKSpendableOutputDescriptor *NONNULL_PTR this_arg); +struct LDKPaymentRelay PaymentRelay_clone(const struct LDKPaymentRelay *NONNULL_PTR orig); /** - * Frees any resources used by the ChannelDerivationParameters, if is_owned is set and inner is non-NULL. + * Frees any resources used by the PaymentConstraints, if is_owned is set and inner is non-NULL. */ -void ChannelDerivationParameters_free(struct LDKChannelDerivationParameters this_obj); +void PaymentConstraints_free(struct LDKPaymentConstraints this_obj); /** - * The value in satoshis of the channel we're attempting to spend the anchor output of. + * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. */ -uint64_t ChannelDerivationParameters_get_value_satoshis(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); +uint32_t PaymentConstraints_get_max_cltv_expiry(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); /** - * The value in satoshis of the channel we're attempting to spend the anchor output of. + * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. */ -void ChannelDerivationParameters_set_value_satoshis(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, uint64_t val); +void PaymentConstraints_set_max_cltv_expiry(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint32_t val); /** - * The unique identifier to re-derive the signer for the associated channel. + * The minimum value, in msat, that may be accepted by the node corresponding to this + * [`BlindedHop`]. */ -const uint8_t (*ChannelDerivationParameters_get_keys_id(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr))[32]; +uint64_t PaymentConstraints_get_htlc_minimum_msat(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); /** - * The unique identifier to re-derive the signer for the associated channel. + * The minimum value, in msat, that may be accepted by the node corresponding to this + * [`BlindedHop`]. */ -void ChannelDerivationParameters_set_keys_id(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void PaymentConstraints_set_htlc_minimum_msat(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint64_t val); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. + * Constructs a new PaymentConstraints given each field */ -struct LDKChannelTransactionParameters ChannelDerivationParameters_get_transaction_parameters(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPaymentConstraints PaymentConstraints_new(uint32_t max_cltv_expiry_arg, uint64_t htlc_minimum_msat_arg); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. + * Creates a copy of the PaymentConstraints */ -void ChannelDerivationParameters_set_transaction_parameters(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); +struct LDKPaymentConstraints PaymentConstraints_clone(const struct LDKPaymentConstraints *NONNULL_PTR orig); /** - * Constructs a new ChannelDerivationParameters given each field + * Frees any resources used by the PaymentContext */ -MUST_USE_RES struct LDKChannelDerivationParameters ChannelDerivationParameters_new(uint64_t value_satoshis_arg, struct LDKThirtyTwoBytes keys_id_arg, struct LDKChannelTransactionParameters transaction_parameters_arg); +void PaymentContext_free(struct LDKPaymentContext this_ptr); /** - * Creates a copy of the ChannelDerivationParameters + * Creates a copy of the PaymentContext */ -struct LDKChannelDerivationParameters ChannelDerivationParameters_clone(const struct LDKChannelDerivationParameters *NONNULL_PTR orig); +struct LDKPaymentContext PaymentContext_clone(const struct LDKPaymentContext *NONNULL_PTR orig); /** - * Checks if two ChannelDerivationParameterss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new Bolt12Offer-variant PaymentContext */ -bool ChannelDerivationParameters_eq(const struct LDKChannelDerivationParameters *NONNULL_PTR a, const struct LDKChannelDerivationParameters *NONNULL_PTR b); +struct LDKPaymentContext PaymentContext_bolt12_offer(struct LDKBolt12OfferContext a); /** - * Serialize the ChannelDerivationParameters object into a byte array which can be read by ChannelDerivationParameters_read + * Utility method to constructs a new Bolt12Refund-variant PaymentContext */ -struct LDKCVec_u8Z ChannelDerivationParameters_write(const struct LDKChannelDerivationParameters *NONNULL_PTR obj); +struct LDKPaymentContext PaymentContext_bolt12_refund(struct LDKBolt12RefundContext a); /** - * Read a ChannelDerivationParameters from a byte array, created by ChannelDerivationParameters_write + * Checks if two PaymentContexts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCResult_ChannelDerivationParametersDecodeErrorZ ChannelDerivationParameters_read(struct LDKu8slice ser); +bool PaymentContext_eq(const struct LDKPaymentContext *NONNULL_PTR a, const struct LDKPaymentContext *NONNULL_PTR b); /** - * Frees any resources used by the HTLCDescriptor, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Bolt12OfferContext, if is_owned is set and inner is non-NULL. */ -void HTLCDescriptor_free(struct LDKHTLCDescriptor this_obj); +void Bolt12OfferContext_free(struct LDKBolt12OfferContext this_obj); /** - * The parameters required to derive the signer for the HTLC input. + * The identifier of the [`Offer`]. + * + * [`Offer`]: crate::offers::offer::Offer */ -struct LDKChannelDerivationParameters HTLCDescriptor_get_channel_derivation_parameters(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +struct LDKOfferId Bolt12OfferContext_get_offer_id(const struct LDKBolt12OfferContext *NONNULL_PTR this_ptr); /** - * The parameters required to derive the signer for the HTLC input. + * The identifier of the [`Offer`]. + * + * [`Offer`]: crate::offers::offer::Offer */ -void HTLCDescriptor_set_channel_derivation_parameters(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); +void Bolt12OfferContext_set_offer_id(struct LDKBolt12OfferContext *NONNULL_PTR this_ptr, struct LDKOfferId val); /** - * The txid of the commitment transaction in which the HTLC output lives. + * Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -const uint8_t (*HTLCDescriptor_get_commitment_txid(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr))[32]; +struct LDKInvoiceRequestFields Bolt12OfferContext_get_invoice_request(const struct LDKBolt12OfferContext *NONNULL_PTR this_ptr); /** - * The txid of the commitment transaction in which the HTLC output lives. + * Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -void HTLCDescriptor_set_commitment_txid(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void Bolt12OfferContext_set_invoice_request(struct LDKBolt12OfferContext *NONNULL_PTR this_ptr, struct LDKInvoiceRequestFields val); /** - * The number of the commitment transaction in which the HTLC output lives. + * Constructs a new Bolt12OfferContext given each field */ -uint64_t HTLCDescriptor_get_per_commitment_number(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKBolt12OfferContext Bolt12OfferContext_new(struct LDKOfferId offer_id_arg, struct LDKInvoiceRequestFields invoice_request_arg); /** - * The number of the commitment transaction in which the HTLC output lives. + * Creates a copy of the Bolt12OfferContext */ -void HTLCDescriptor_set_per_commitment_number(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint64_t val); +struct LDKBolt12OfferContext Bolt12OfferContext_clone(const struct LDKBolt12OfferContext *NONNULL_PTR orig); /** - * The key tweak corresponding to the number of the commitment transaction in which the HTLC - * output lives. This tweak is applied to all the basepoints for both parties in the channel to - * arrive at unique keys per commitment. - * - * See for more info. + * Checks if two Bolt12OfferContexts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKPublicKey HTLCDescriptor_get_per_commitment_point(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +bool Bolt12OfferContext_eq(const struct LDKBolt12OfferContext *NONNULL_PTR a, const struct LDKBolt12OfferContext *NONNULL_PTR b); /** - * The key tweak corresponding to the number of the commitment transaction in which the HTLC - * output lives. This tweak is applied to all the basepoints for both parties in the channel to - * arrive at unique keys per commitment. - * - * See for more info. + * Frees any resources used by the Bolt12RefundContext, if is_owned is set and inner is non-NULL. */ -void HTLCDescriptor_set_per_commitment_point(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void Bolt12RefundContext_free(struct LDKBolt12RefundContext this_obj); /** - * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs - * originating from a channel supporting anchor outputs, otherwise it is the channel's - * negotiated feerate at the time the commitment transaction was built. + * Constructs a new Bolt12RefundContext given each field */ -uint32_t HTLCDescriptor_get_feerate_per_kw(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKBolt12RefundContext Bolt12RefundContext_new(void); /** - * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs - * originating from a channel supporting anchor outputs, otherwise it is the channel's - * negotiated feerate at the time the commitment transaction was built. + * Creates a copy of the Bolt12RefundContext */ -void HTLCDescriptor_set_feerate_per_kw(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint32_t val); +struct LDKBolt12RefundContext Bolt12RefundContext_clone(const struct LDKBolt12RefundContext *NONNULL_PTR orig); /** - * The details of the HTLC as it appears in the commitment transaction. + * Checks if two Bolt12RefundContexts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKHTLCOutputInCommitment HTLCDescriptor_get_htlc(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +bool Bolt12RefundContext_eq(const struct LDKBolt12RefundContext *NONNULL_PTR a, const struct LDKBolt12RefundContext *NONNULL_PTR b); /** - * The details of the HTLC as it appears in the commitment transaction. + * Serialize the ForwardTlvs object into a byte array which can be read by ForwardTlvs_read */ -void HTLCDescriptor_set_htlc(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKHTLCOutputInCommitment val); +struct LDKCVec_u8Z ForwardTlvs_write(const struct LDKForwardTlvs *NONNULL_PTR obj); /** - * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be - * taken. + * Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read */ -struct LDKCOption_ThirtyTwoBytesZ HTLCDescriptor_get_preimage(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ReceiveTlvs_write(const struct LDKReceiveTlvs *NONNULL_PTR obj); /** - * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be - * taken. + * Serialize the UnauthenticatedReceiveTlvs object into a byte array which can be read by UnauthenticatedReceiveTlvs_read */ -void HTLCDescriptor_set_preimage(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); +struct LDKCVec_u8Z UnauthenticatedReceiveTlvs_write(const struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR obj); /** - * The counterparty's signature required to spend the HTLC output. + * Serialize the PaymentRelay object into a byte array which can be read by PaymentRelay_read */ -struct LDKECDSASignature HTLCDescriptor_get_counterparty_sig(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z PaymentRelay_write(const struct LDKPaymentRelay *NONNULL_PTR obj); /** - * The counterparty's signature required to spend the HTLC output. + * Read a PaymentRelay from a byte array, created by PaymentRelay_write */ -void HTLCDescriptor_set_counterparty_sig(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +struct LDKCResult_PaymentRelayDecodeErrorZ PaymentRelay_read(struct LDKu8slice ser); /** - * Constructs a new HTLCDescriptor given each field + * Serialize the PaymentConstraints object into a byte array which can be read by PaymentConstraints_read */ -MUST_USE_RES struct LDKHTLCDescriptor HTLCDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKThirtyTwoBytes commitment_txid_arg, uint64_t per_commitment_number_arg, struct LDKPublicKey per_commitment_point_arg, uint32_t feerate_per_kw_arg, struct LDKHTLCOutputInCommitment htlc_arg, struct LDKCOption_ThirtyTwoBytesZ preimage_arg, struct LDKECDSASignature counterparty_sig_arg); +struct LDKCVec_u8Z PaymentConstraints_write(const struct LDKPaymentConstraints *NONNULL_PTR obj); /** - * Creates a copy of the HTLCDescriptor + * Read a PaymentConstraints from a byte array, created by PaymentConstraints_write */ -struct LDKHTLCDescriptor HTLCDescriptor_clone(const struct LDKHTLCDescriptor *NONNULL_PTR orig); +struct LDKCResult_PaymentConstraintsDecodeErrorZ PaymentConstraints_read(struct LDKu8slice ser); /** - * Checks if two HTLCDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the PaymentContext object into a byte array which can be read by PaymentContext_read */ -bool HTLCDescriptor_eq(const struct LDKHTLCDescriptor *NONNULL_PTR a, const struct LDKHTLCDescriptor *NONNULL_PTR b); +struct LDKCVec_u8Z PaymentContext_write(const struct LDKPaymentContext *NONNULL_PTR obj); /** - * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read + * Read a PaymentContext from a byte array, created by PaymentContext_write */ -struct LDKCVec_u8Z HTLCDescriptor_write(const struct LDKHTLCDescriptor *NONNULL_PTR obj); +struct LDKCResult_PaymentContextDecodeErrorZ PaymentContext_read(struct LDKu8slice ser); /** - * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write + * Serialize the Bolt12OfferContext object into a byte array which can be read by Bolt12OfferContext_read */ -struct LDKCResult_HTLCDescriptorDecodeErrorZ HTLCDescriptor_read(struct LDKu8slice ser); +struct LDKCVec_u8Z Bolt12OfferContext_write(const struct LDKBolt12OfferContext *NONNULL_PTR obj); /** - * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint - * being spent by the HTLC input in the HTLC transaction. + * Read a Bolt12OfferContext from a byte array, created by Bolt12OfferContext_write */ -MUST_USE_RES struct LDKOutPoint HTLCDescriptor_outpoint(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +struct LDKCResult_Bolt12OfferContextDecodeErrorZ Bolt12OfferContext_read(struct LDKu8slice ser); /** - * Returns the UTXO to be spent by the HTLC input, which can be obtained via - * [`Self::unsigned_tx_input`]. + * Serialize the Bolt12RefundContext object into a byte array which can be read by Bolt12RefundContext_read */ -MUST_USE_RES struct LDKTxOut HTLCDescriptor_previous_utxo(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +struct LDKCVec_u8Z Bolt12RefundContext_write(const struct LDKBolt12RefundContext *NONNULL_PTR obj); /** - * Returns the unsigned transaction input spending the HTLC output in the commitment - * transaction. + * Read a Bolt12RefundContext from a byte array, created by Bolt12RefundContext_write */ -MUST_USE_RES struct LDKTxIn HTLCDescriptor_unsigned_tx_input(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +struct LDKCResult_Bolt12RefundContextDecodeErrorZ Bolt12RefundContext_read(struct LDKu8slice ser); /** - * Returns the delayed output created as a result of spending the HTLC output in the commitment - * transaction. + * Frees any resources used by the BlindedMessagePath, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKTxOut HTLCDescriptor_tx_output(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +void BlindedMessagePath_free(struct LDKBlindedMessagePath this_obj); /** - * Returns the witness script of the HTLC output in the commitment transaction. + * Creates a copy of the BlindedMessagePath */ -MUST_USE_RES struct LDKCVec_u8Z HTLCDescriptor_witness_script(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +struct LDKBlindedMessagePath BlindedMessagePath_clone(const struct LDKBlindedMessagePath *NONNULL_PTR orig); /** - * Returns the fully signed witness required to spend the HTLC output in the commitment - * transaction. + * Generates a non-cryptographic 64-bit hash of the BlindedMessagePath. */ -MUST_USE_RES struct LDKWitness HTLCDescriptor_tx_input_witness(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature, struct LDKu8slice witness_script); +uint64_t BlindedMessagePath_hash(const struct LDKBlindedMessagePath *NONNULL_PTR o); /** - * Derives the channel signer required to sign the HTLC input. + * Checks if two BlindedMessagePaths contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKEcdsaChannelSigner HTLCDescriptor_derive_channel_signer(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); +bool BlindedMessagePath_eq(const struct LDKBlindedMessagePath *NONNULL_PTR a, const struct LDKBlindedMessagePath *NONNULL_PTR b); /** - * Calls the free function if one is set + * Serialize the BlindedMessagePath object into a byte array which can be read by BlindedMessagePath_read */ -void ChannelSigner_free(struct LDKChannelSigner this_ptr); +struct LDKCVec_u8Z BlindedMessagePath_write(const struct LDKBlindedMessagePath *NONNULL_PTR obj); /** - * Creates a copy of the Recipient + * Read a BlindedMessagePath from a byte array, created by BlindedMessagePath_write */ -enum LDKRecipient Recipient_clone(const enum LDKRecipient *NONNULL_PTR orig); +struct LDKCResult_BlindedMessagePathDecodeErrorZ BlindedMessagePath_read(struct LDKu8slice ser); /** - * Utility method to constructs a new Node-variant Recipient + * Create a one-hop blinded path for a message. */ -enum LDKRecipient Recipient_node(void); +MUST_USE_RES struct LDKCResult_BlindedMessagePathNoneZ BlindedMessagePath_one_hop(struct LDKPublicKey recipient_node_id, struct LDKMessageContext context, struct LDKEntropySource entropy_source); /** - * Utility method to constructs a new PhantomNode-variant Recipient + * Create a path for an onion message, to be forwarded along `node_pks`. The last node + * pubkey in `node_pks` will be the destination node. + * + * Errors if no hops are provided or if `node_pk`(s) are invalid. */ -enum LDKRecipient Recipient_phantom_node(void); +MUST_USE_RES struct LDKCResult_BlindedMessagePathNoneZ BlindedMessagePath_new(struct LDKCVec_MessageForwardNodeZ intermediate_nodes, struct LDKPublicKey recipient_node_id, struct LDKMessageContext context, struct LDKEntropySource entropy_source); /** - * Calls the free function if one is set + * Attempts to a use a compact representation for the [`IntroductionNode`] by using a directed + * short channel id from a channel in `network_graph` leading to the introduction node. + * + * While this may result in a smaller encoding, there is a trade off in that the path may + * become invalid if the channel is closed or hasn't been propagated via gossip. Therefore, + * calling this may not be suitable for long-lived blinded paths. */ -void EntropySource_free(struct LDKEntropySource this_ptr); +void BlindedMessagePath_use_compact_introduction_node(struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); /** - * Calls the free function if one is set + * Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., + * it is found in the network graph). + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void NodeSigner_free(struct LDKNodeSigner this_ptr); +MUST_USE_RES struct LDKNodeId BlindedMessagePath_public_introduction_node_id(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); /** - * Calls the free function if one is set + * The [`IntroductionNode`] of the blinded path. */ -void OutputSpender_free(struct LDKOutputSpender this_ptr); +MUST_USE_RES struct LDKIntroductionNode BlindedMessagePath_introduction_node(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the message. + * + * [`encrypted_payload`]: BlindedHop::encrypted_payload */ -void SignerProvider_free(struct LDKSignerProvider this_ptr); +MUST_USE_RES struct LDKPublicKey BlindedMessagePath_blinding_point(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * The [`BlindedHop`]s within the blinded path. */ -void ChangeDestinationSource_free(struct LDKChangeDestinationSource this_ptr); +MUST_USE_RES struct LDKCVec_BlindedHopZ BlindedMessagePath_blinded_hops(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); /** - * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. + * Advance the blinded onion message path by one hop, making the second hop into the new + * introduction node. + * + * Will only modify `self` when returning `Ok`. */ -void InMemorySigner_free(struct LDKInMemorySigner this_obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedMessagePath_advance_path_by_one(struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup); /** - * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the - * holder's anchor output in a commitment transaction, if one is present. + * Frees any resources used by the NextMessageHop */ -const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +void NextMessageHop_free(struct LDKNextMessageHop this_ptr); /** - * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the - * holder's anchor output in a commitment transaction, if one is present. + * Creates a copy of the NextMessageHop */ -void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +struct LDKNextMessageHop NextMessageHop_clone(const struct LDKNextMessageHop *NONNULL_PTR orig); /** - * Holder secret key for blinded revocation pubkey. + * Utility method to constructs a new NodeId-variant NextMessageHop */ -const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +struct LDKNextMessageHop NextMessageHop_node_id(struct LDKPublicKey a); /** - * Holder secret key for blinded revocation pubkey. + * Utility method to constructs a new ShortChannelId-variant NextMessageHop */ -void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +struct LDKNextMessageHop NextMessageHop_short_channel_id(uint64_t a); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. + * Generates a non-cryptographic 64-bit hash of the NextMessageHop. */ -const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +uint64_t NextMessageHop_hash(const struct LDKNextMessageHop *NONNULL_PTR o); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. + * Checks if two NextMessageHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +bool NextMessageHop_eq(const struct LDKNextMessageHop *NONNULL_PTR a, const struct LDKNextMessageHop *NONNULL_PTR b); /** - * Holder secret key used in an HTLC transaction. + * Frees any resources used by the MessageForwardNode, if is_owned is set and inner is non-NULL. */ -const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +void MessageForwardNode_free(struct LDKMessageForwardNode this_obj); /** - * Holder secret key used in an HTLC transaction. + * This node's pubkey. */ -void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +struct LDKPublicKey MessageForwardNode_get_node_id(const struct LDKMessageForwardNode *NONNULL_PTR this_ptr); /** - * Holder HTLC secret key used in commitment transaction HTLC outputs. + * This node's pubkey. */ -const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +void MessageForwardNode_set_node_id(struct LDKMessageForwardNode *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Holder HTLC secret key used in commitment transaction HTLC outputs. + * The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s + * `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a + * more compact representation. */ -void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +struct LDKCOption_u64Z MessageForwardNode_get_short_channel_id(const struct LDKMessageForwardNode *NONNULL_PTR this_ptr); /** - * Commitment seed. + * The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s + * `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a + * more compact representation. */ -const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +void MessageForwardNode_set_short_channel_id(struct LDKMessageForwardNode *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Commitment seed. + * Constructs a new MessageForwardNode given each field */ -void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKMessageForwardNode MessageForwardNode_new(struct LDKPublicKey node_id_arg, struct LDKCOption_u64Z short_channel_id_arg); /** - * Creates a copy of the InMemorySigner + * Creates a copy of the MessageForwardNode */ -struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); +struct LDKMessageForwardNode MessageForwardNode_clone(const struct LDKMessageForwardNode *NONNULL_PTR orig); /** - * Creates a new [`InMemorySigner`]. + * Generates a non-cryptographic 64-bit hash of the MessageForwardNode. */ -MUST_USE_RES struct LDKInMemorySigner InMemorySigner_new(struct LDKSecretKey funding_key, struct LDKSecretKey revocation_base_key, struct LDKSecretKey payment_key, struct LDKSecretKey delayed_payment_base_key, struct LDKSecretKey htlc_base_key, struct LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id, struct LDKThirtyTwoBytes rand_bytes_unique_start); +uint64_t MessageForwardNode_hash(const struct LDKMessageForwardNode *NONNULL_PTR o); /** - * Returns the counterparty's pubkeys. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two MessageForwardNodes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +bool MessageForwardNode_eq(const struct LDKMessageForwardNode *NONNULL_PTR a, const struct LDKMessageForwardNode *NONNULL_PTR b); /** - * Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable - * transactions, i.e., the amount of time that we have to wait to recover our funds if we - * broadcast a transaction. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * Frees any resources used by the MessageContext */ -MUST_USE_RES struct LDKCOption_u16Z InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void MessageContext_free(struct LDKMessageContext this_ptr); /** - * Returns the `contest_delay` value specified by us and applied on transactions broadcastable - * by our counterparty, i.e., the amount of time that they have to wait to recover their funds - * if they broadcast a transaction. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * Creates a copy of the MessageContext */ -MUST_USE_RES struct LDKCOption_u16Z InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKMessageContext MessageContext_clone(const struct LDKMessageContext *NONNULL_PTR orig); /** - * Returns whether the holder is the initiator. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * Utility method to constructs a new Offers-variant MessageContext */ -MUST_USE_RES struct LDKCOption_boolZ InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKMessageContext MessageContext_offers(struct LDKOffersContext a); /** - * Funding outpoint - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new AsyncPayments-variant MessageContext */ -MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKMessageContext MessageContext_async_payments(struct LDKAsyncPaymentsContext a); /** - * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or - * building transactions. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new DNSResolver-variant MessageContext */ -MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKMessageContext MessageContext_dnsresolver(struct LDKDNSResolverContext a); /** - * Returns the channel type features of the channel parameters. Should be helpful for - * determining a channel's category, i. e. legacy/anchors/taproot/etc. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new Custom-variant MessageContext */ -MUST_USE_RES struct LDKChannelTypeFeatures InMemorySigner_channel_type_features(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKMessageContext MessageContext_custom(struct LDKCVec_u8Z a); /** - * Sign the single input of `spend_tx` at index `input_idx`, which spends the output described - * by `descriptor`, returning the witness stack for the input. - * - * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, - * is not spending the outpoint described by [`descriptor.outpoint`], - * or if an output descriptor `script_pubkey` does not match the one we can spend. - * - * [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint + * Frees any resources used by the OffersContext */ -MUST_USE_RES struct LDKCResult_WitnessNoneZ InMemorySigner_sign_counterparty_payment_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR descriptor); +void OffersContext_free(struct LDKOffersContext this_ptr); /** - * Sign the single input of `spend_tx` at index `input_idx` which spends the output - * described by `descriptor`, returning the witness stack for the input. - * - * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, - * is not spending the outpoint described by [`descriptor.outpoint`], does not have a - * sequence set to [`descriptor.to_self_delay`], or if an output descriptor - * `script_pubkey` does not match the one we can spend. - * - * [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint - * [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay + * Creates a copy of the OffersContext */ -MUST_USE_RES struct LDKCResult_WitnessNoneZ InMemorySigner_sign_dynamic_p2wsh_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); +struct LDKOffersContext OffersContext_clone(const struct LDKOffersContext *NONNULL_PTR orig); /** - * Constructs a new EntropySource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is + * Utility method to constructs a new InvoiceRequest-variant OffersContext */ -struct LDKEntropySource InMemorySigner_as_EntropySource(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKOffersContext OffersContext_invoice_request(struct LDKNonce nonce); /** - * Constructs a new ChannelSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is + * Utility method to constructs a new OutboundPayment-variant OffersContext */ -struct LDKChannelSigner InMemorySigner_as_ChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKOffersContext OffersContext_outbound_payment(struct LDKThirtyTwoBytes payment_id, struct LDKNonce nonce, struct LDKThirtyTwoBytes hmac); /** - * Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is + * Utility method to constructs a new InboundPayment-variant OffersContext */ -struct LDKEcdsaChannelSigner InMemorySigner_as_EcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKOffersContext OffersContext_inbound_payment(struct LDKThirtyTwoBytes payment_hash, struct LDKNonce nonce, struct LDKThirtyTwoBytes hmac); /** - * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read + * Checks if two OffersContexts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); +bool OffersContext_eq(const struct LDKOffersContext *NONNULL_PTR a, const struct LDKOffersContext *NONNULL_PTR b); /** - * Read a InMemorySigner from a byte array, created by InMemorySigner_write + * Frees any resources used by the AsyncPaymentsContext */ -struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKEntropySource arg); +void AsyncPaymentsContext_free(struct LDKAsyncPaymentsContext this_ptr); /** - * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. + * Creates a copy of the AsyncPaymentsContext */ -void KeysManager_free(struct LDKKeysManager this_obj); +struct LDKAsyncPaymentsContext AsyncPaymentsContext_clone(const struct LDKAsyncPaymentsContext *NONNULL_PTR orig); /** - * Constructs a [`KeysManager`] from a 32-byte seed. If the seed is in some way biased (e.g., - * your CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). - * `starting_time` isn't strictly required to actually be a time, but it must absolutely, - * without a doubt, be unique to this instance. ie if you start multiple times with the same - * `seed`, `starting_time` must be unique to each run. Thus, the easiest way to achieve this - * is to simply use the current time (with very high precision). - * - * The `seed` MUST be backed up safely prior to use so that the keys can be re-created, however, - * obviously, `starting_time` should be unique every time you reload the library - it is only - * used to generate new ephemeral key data (which will be stored by the individual channel if - * necessary). - * - * Note that the seed is required to recover certain on-chain funds independent of - * [`ChannelMonitor`] data, though a current copy of [`ChannelMonitor`] data is also required - * for any channel, and some on-chain during-closing funds. - * - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * Utility method to constructs a new OutboundPayment-variant AsyncPaymentsContext */ -MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); +struct LDKAsyncPaymentsContext AsyncPaymentsContext_outbound_payment(struct LDKThirtyTwoBytes payment_id, struct LDKNonce nonce, struct LDKThirtyTwoBytes hmac); /** - * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. + * Serialize the MessageContext object into a byte array which can be read by MessageContext_read */ -MUST_USE_RES struct LDKSecretKey KeysManager_get_node_secret_key(const struct LDKKeysManager *NONNULL_PTR this_arg); +struct LDKCVec_u8Z MessageContext_write(const struct LDKMessageContext *NONNULL_PTR obj); /** - * Derive an old [`EcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. + * Read a MessageContext from a byte array, created by MessageContext_write */ -MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); +struct LDKCResult_MessageContextDecodeErrorZ MessageContext_read(struct LDKu8slice ser); /** - * Signs the given [`Psbt`] which spends the given [`SpendableOutputDescriptor`]s. - * The resulting inputs will be finalized and the PSBT will be ready for broadcast if there - * are no other inputs that need signing. - * - * Returns `Err(())` if the PSBT is missing a descriptor or if we fail to sign. - * - * May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used - * this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. + * Serialize the OffersContext object into a byte array which can be read by OffersContext_read */ -MUST_USE_RES struct LDKCResult_CVec_u8ZNoneZ KeysManager_sign_spendable_outputs_psbt(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_u8Z psbt); +struct LDKCVec_u8Z OffersContext_write(const struct LDKOffersContext *NONNULL_PTR obj); /** - * Constructs a new EntropySource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is + * Read a OffersContext from a byte array, created by OffersContext_write */ -struct LDKEntropySource KeysManager_as_EntropySource(const struct LDKKeysManager *NONNULL_PTR this_arg); +struct LDKCResult_OffersContextDecodeErrorZ OffersContext_read(struct LDKu8slice ser); /** - * Constructs a new NodeSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is + * Serialize the AsyncPaymentsContext object into a byte array which can be read by AsyncPaymentsContext_read */ -struct LDKNodeSigner KeysManager_as_NodeSigner(const struct LDKKeysManager *NONNULL_PTR this_arg); +struct LDKCVec_u8Z AsyncPaymentsContext_write(const struct LDKAsyncPaymentsContext *NONNULL_PTR obj); /** - * Constructs a new OutputSpender which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is + * Read a AsyncPaymentsContext from a byte array, created by AsyncPaymentsContext_write */ -struct LDKOutputSpender KeysManager_as_OutputSpender(const struct LDKKeysManager *NONNULL_PTR this_arg); +struct LDKCResult_AsyncPaymentsContextDecodeErrorZ AsyncPaymentsContext_read(struct LDKu8slice ser); /** - * Constructs a new SignerProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is + * Frees any resources used by the DNSResolverContext, if is_owned is set and inner is non-NULL. */ -struct LDKSignerProvider KeysManager_as_SignerProvider(const struct LDKKeysManager *NONNULL_PTR this_arg); +void DNSResolverContext_free(struct LDKDNSResolverContext this_obj); /** - * Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. + * A nonce which uniquely describes a DNS resolution. + * + * When we receive a DNSSEC proof message, we should check that it was sent over the blinded + * path we included in the request by comparing a stored nonce with this one. */ -void PhantomKeysManager_free(struct LDKPhantomKeysManager this_obj); +const uint8_t (*DNSResolverContext_get_nonce(const struct LDKDNSResolverContext *NONNULL_PTR this_ptr))[16]; /** - * Constructs a new EntropySource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is + * A nonce which uniquely describes a DNS resolution. + * + * When we receive a DNSSEC proof message, we should check that it was sent over the blinded + * path we included in the request by comparing a stored nonce with this one. */ -struct LDKEntropySource PhantomKeysManager_as_EntropySource(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +void DNSResolverContext_set_nonce(struct LDKDNSResolverContext *NONNULL_PTR this_ptr, struct LDKSixteenBytes val); /** - * Constructs a new NodeSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is + * Constructs a new DNSResolverContext given each field */ -struct LDKNodeSigner PhantomKeysManager_as_NodeSigner(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKDNSResolverContext DNSResolverContext_new(struct LDKSixteenBytes nonce_arg); /** - * Constructs a new OutputSpender which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is + * Creates a copy of the DNSResolverContext */ -struct LDKOutputSpender PhantomKeysManager_as_OutputSpender(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +struct LDKDNSResolverContext DNSResolverContext_clone(const struct LDKDNSResolverContext *NONNULL_PTR orig); /** - * Constructs a new SignerProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is + * Generates a non-cryptographic 64-bit hash of the DNSResolverContext. */ -struct LDKSignerProvider PhantomKeysManager_as_SignerProvider(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +uint64_t DNSResolverContext_hash(const struct LDKDNSResolverContext *NONNULL_PTR o); /** - * Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed` - * that is shared across all nodes that intend to participate in [phantom node payments] - * together. - * - * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and - * `starting_time_nanos`. - * - * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the - * same across restarts, or else inbound payments may fail. - * - * [phantom node payments]: PhantomKeysManager + * Checks if two DNSResolverContexts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKPhantomKeysManager PhantomKeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos, const uint8_t (*cross_node_seed)[32]); +bool DNSResolverContext_eq(const struct LDKDNSResolverContext *NONNULL_PTR a, const struct LDKDNSResolverContext *NONNULL_PTR b); /** - * See [`KeysManager::derive_channel_keys`] for documentation on this method. + * Serialize the DNSResolverContext object into a byte array which can be read by DNSResolverContext_read */ -MUST_USE_RES struct LDKInMemorySigner PhantomKeysManager_derive_channel_keys(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); +struct LDKCVec_u8Z DNSResolverContext_write(const struct LDKDNSResolverContext *NONNULL_PTR obj); /** - * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. + * Read a DNSResolverContext from a byte array, created by DNSResolverContext_write */ -MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +struct LDKCResult_DNSResolverContextDecodeErrorZ DNSResolverContext_read(struct LDKu8slice ser); /** - * Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the - * last-hop onion data, etc. + * Frees any resources used by the FundingInfo */ -MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_phantom_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +void FundingInfo_free(struct LDKFundingInfo this_ptr); /** - * Frees any resources used by the RandomBytes, if is_owned is set and inner is non-NULL. + * Creates a copy of the FundingInfo */ -void RandomBytes_free(struct LDKRandomBytes this_obj); +struct LDKFundingInfo FundingInfo_clone(const struct LDKFundingInfo *NONNULL_PTR orig); /** - * Creates a new instance using the given seed. + * Utility method to constructs a new Tx-variant FundingInfo */ -MUST_USE_RES struct LDKRandomBytes RandomBytes_new(struct LDKThirtyTwoBytes seed); +struct LDKFundingInfo FundingInfo_tx(struct LDKTransaction transaction); /** - * Constructs a new EntropySource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is + * Utility method to constructs a new OutPoint-variant FundingInfo */ -struct LDKEntropySource RandomBytes_as_EntropySource(const struct LDKRandomBytes *NONNULL_PTR this_arg); +struct LDKFundingInfo FundingInfo_out_point(struct LDKOutPoint outpoint); /** - * Creates a copy of a EcdsaChannelSigner + * Checks if two FundingInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKEcdsaChannelSigner EcdsaChannelSigner_clone(const struct LDKEcdsaChannelSigner *NONNULL_PTR orig); +bool FundingInfo_eq(const struct LDKFundingInfo *NONNULL_PTR a, const struct LDKFundingInfo *NONNULL_PTR b); /** - * Calls the free function if one is set + * Serialize the FundingInfo object into a byte array which can be read by FundingInfo_read */ -void EcdsaChannelSigner_free(struct LDKEcdsaChannelSigner this_ptr); +struct LDKCVec_u8Z FundingInfo_write(const struct LDKFundingInfo *NONNULL_PTR obj); /** - * Calls the free function if one is set + * Read a FundingInfo from a byte array, created by FundingInfo_write */ -void AsyncPaymentsMessageHandler_free(struct LDKAsyncPaymentsMessageHandler this_ptr); +struct LDKCResult_FundingInfoDecodeErrorZ FundingInfo_read(struct LDKu8slice ser); /** - * Frees any resources used by the AsyncPaymentsMessage + * Frees any resources used by the PaymentPurpose */ -void AsyncPaymentsMessage_free(struct LDKAsyncPaymentsMessage this_ptr); +void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); /** - * Creates a copy of the AsyncPaymentsMessage + * Creates a copy of the PaymentPurpose */ -struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_clone(const struct LDKAsyncPaymentsMessage *NONNULL_PTR orig); +struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig); /** - * Utility method to constructs a new HeldHtlcAvailable-variant AsyncPaymentsMessage + * Utility method to constructs a new Bolt11InvoicePayment-variant PaymentPurpose */ -struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_held_htlc_available(struct LDKHeldHtlcAvailable a); +struct LDKPaymentPurpose PaymentPurpose_bolt11_invoice_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret); /** - * Utility method to constructs a new ReleaseHeldHtlc-variant AsyncPaymentsMessage + * Utility method to constructs a new Bolt12OfferPayment-variant PaymentPurpose */ -struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_release_held_htlc(struct LDKReleaseHeldHtlc a); +struct LDKPaymentPurpose PaymentPurpose_bolt12_offer_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret, struct LDKBolt12OfferContext payment_context); /** - * Frees any resources used by the HeldHtlcAvailable, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Bolt12RefundPayment-variant PaymentPurpose */ -void HeldHtlcAvailable_free(struct LDKHeldHtlcAvailable this_obj); +struct LDKPaymentPurpose PaymentPurpose_bolt12_refund_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret, struct LDKBolt12RefundContext payment_context); /** - * Constructs a new HeldHtlcAvailable given each field + * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose */ -MUST_USE_RES struct LDKHeldHtlcAvailable HeldHtlcAvailable_new(void); +struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a); /** - * Creates a copy of the HeldHtlcAvailable + * Checks if two PaymentPurposes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKHeldHtlcAvailable HeldHtlcAvailable_clone(const struct LDKHeldHtlcAvailable *NONNULL_PTR orig); +bool PaymentPurpose_eq(const struct LDKPaymentPurpose *NONNULL_PTR a, const struct LDKPaymentPurpose *NONNULL_PTR b); /** - * Frees any resources used by the ReleaseHeldHtlc, if is_owned is set and inner is non-NULL. + * Returns the preimage for this payment, if it is known. */ -void ReleaseHeldHtlc_free(struct LDKReleaseHeldHtlc this_obj); +MUST_USE_RES struct LDKCOption_ThirtyTwoBytesZ PaymentPurpose_preimage(const struct LDKPaymentPurpose *NONNULL_PTR this_arg); /** - * Constructs a new ReleaseHeldHtlc given each field + * Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read */ -MUST_USE_RES struct LDKReleaseHeldHtlc ReleaseHeldHtlc_new(void); +struct LDKCVec_u8Z PaymentPurpose_write(const struct LDKPaymentPurpose *NONNULL_PTR obj); /** - * Creates a copy of the ReleaseHeldHtlc + * Read a PaymentPurpose from a byte array, created by PaymentPurpose_write */ -struct LDKReleaseHeldHtlc ReleaseHeldHtlc_clone(const struct LDKReleaseHeldHtlc *NONNULL_PTR orig); +struct LDKCResult_PaymentPurposeDecodeErrorZ PaymentPurpose_read(struct LDKu8slice ser); /** - * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is + * Frees any resources used by the ClaimedHTLC, if is_owned is set and inner is non-NULL. */ -struct LDKOnionMessageContents ReleaseHeldHtlc_as_OnionMessageContents(const struct LDKReleaseHeldHtlc *NONNULL_PTR this_arg); +void ClaimedHTLC_free(struct LDKClaimedHTLC this_obj); /** - * Serialize the HeldHtlcAvailable object into a byte array which can be read by HeldHtlcAvailable_read + * The `channel_id` of the channel over which the HTLC was received. */ -struct LDKCVec_u8Z HeldHtlcAvailable_write(const struct LDKHeldHtlcAvailable *NONNULL_PTR obj); +struct LDKChannelId ClaimedHTLC_get_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Read a HeldHtlcAvailable from a byte array, created by HeldHtlcAvailable_write + * The `channel_id` of the channel over which the HTLC was received. */ -struct LDKCResult_HeldHtlcAvailableDecodeErrorZ HeldHtlcAvailable_read(struct LDKu8slice ser); +void ClaimedHTLC_set_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Serialize the ReleaseHeldHtlc object into a byte array which can be read by ReleaseHeldHtlc_read + * The `user_channel_id` of the channel over which the HTLC was received. This is the value + * passed in to [`ChannelManager::create_channel`] for outbound channels, or to + * [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. + * + * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This + * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but + * was not actually claimed until after upgrading.) + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels */ -struct LDKCVec_u8Z ReleaseHeldHtlc_write(const struct LDKReleaseHeldHtlc *NONNULL_PTR obj); +struct LDKU128 ClaimedHTLC_get_user_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Read a ReleaseHeldHtlc from a byte array, created by ReleaseHeldHtlc_write + * The `user_channel_id` of the channel over which the HTLC was received. This is the value + * passed in to [`ChannelManager::create_channel`] for outbound channels, or to + * [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. + * + * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This + * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but + * was not actually claimed until after upgrading.) + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels */ -struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ ReleaseHeldHtlc_read(struct LDKu8slice ser); +void ClaimedHTLC_set_user_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKU128 val); /** - * Returns whether `tlv_type` corresponds to a TLV record for async payment messages. + * The block height at which this HTLC expires. */ -MUST_USE_RES bool AsyncPaymentsMessage_is_known_type(uint64_t tlv_type); +uint32_t ClaimedHTLC_get_cltv_expiry(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is + * The block height at which this HTLC expires. */ -struct LDKOnionMessageContents AsyncPaymentsMessage_as_OnionMessageContents(const struct LDKAsyncPaymentsMessage *NONNULL_PTR this_arg); +void ClaimedHTLC_set_cltv_expiry(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint32_t val); /** - * Serialize the AsyncPaymentsMessage object into a byte array which can be read by AsyncPaymentsMessage_read + * The amount (in msats) of this part of an MPP. */ -struct LDKCVec_u8Z AsyncPaymentsMessage_write(const struct LDKAsyncPaymentsMessage *NONNULL_PTR obj); +uint64_t ClaimedHTLC_get_value_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Read a AsyncPaymentsMessage from a byte array, created by AsyncPaymentsMessage_write + * The amount (in msats) of this part of an MPP. */ -struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ AsyncPaymentsMessage_read(struct LDKu8slice ser, uint64_t arg); +void ClaimedHTLC_set_value_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Calls the free function if one is set + * The extra fee our counterparty skimmed off the top of this HTLC, if any. + * + * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to + * 0.0.119. */ -void DNSResolverMessageHandler_free(struct LDKDNSResolverMessageHandler this_ptr); +uint64_t ClaimedHTLC_get_counterparty_skimmed_fee_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Frees any resources used by the DNSResolverMessage + * The extra fee our counterparty skimmed off the top of this HTLC, if any. + * + * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to + * 0.0.119. */ -void DNSResolverMessage_free(struct LDKDNSResolverMessage this_ptr); +void ClaimedHTLC_set_counterparty_skimmed_fee_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the DNSResolverMessage + * Constructs a new ClaimedHTLC given each field */ -struct LDKDNSResolverMessage DNSResolverMessage_clone(const struct LDKDNSResolverMessage *NONNULL_PTR orig); +MUST_USE_RES struct LDKClaimedHTLC ClaimedHTLC_new(struct LDKChannelId channel_id_arg, struct LDKU128 user_channel_id_arg, uint32_t cltv_expiry_arg, uint64_t value_msat_arg, uint64_t counterparty_skimmed_fee_msat_arg); /** - * Utility method to constructs a new DNSSECQuery-variant DNSResolverMessage + * Creates a copy of the ClaimedHTLC */ -struct LDKDNSResolverMessage DNSResolverMessage_dnssecquery(struct LDKDNSSECQuery a); +struct LDKClaimedHTLC ClaimedHTLC_clone(const struct LDKClaimedHTLC *NONNULL_PTR orig); /** - * Utility method to constructs a new DNSSECProof-variant DNSResolverMessage + * Checks if two ClaimedHTLCs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKDNSResolverMessage DNSResolverMessage_dnssecproof(struct LDKDNSSECProof a); +bool ClaimedHTLC_eq(const struct LDKClaimedHTLC *NONNULL_PTR a, const struct LDKClaimedHTLC *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the DNSResolverMessage. + * Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read */ -uint64_t DNSResolverMessage_hash(const struct LDKDNSResolverMessage *NONNULL_PTR o); +struct LDKCVec_u8Z ClaimedHTLC_write(const struct LDKClaimedHTLC *NONNULL_PTR obj); /** - * Checks if two DNSResolverMessages contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write */ -bool DNSResolverMessage_eq(const struct LDKDNSResolverMessage *NONNULL_PTR a, const struct LDKDNSResolverMessage *NONNULL_PTR b); +struct LDKCResult_ClaimedHTLCDecodeErrorZ ClaimedHTLC_read(struct LDKu8slice ser); /** - * Frees any resources used by the DNSSECQuery, if is_owned is set and inner is non-NULL. + * Frees any resources used by the PathFailure */ -void DNSSECQuery_free(struct LDKDNSSECQuery this_obj); +void PathFailure_free(struct LDKPathFailure this_ptr); /** - * Creates a copy of the DNSSECQuery + * Creates a copy of the PathFailure */ -struct LDKDNSSECQuery DNSSECQuery_clone(const struct LDKDNSSECQuery *NONNULL_PTR orig); +struct LDKPathFailure PathFailure_clone(const struct LDKPathFailure *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the DNSSECQuery. + * Utility method to constructs a new InitialSend-variant PathFailure */ -uint64_t DNSSECQuery_hash(const struct LDKDNSSECQuery *NONNULL_PTR o); +struct LDKPathFailure PathFailure_initial_send(struct LDKAPIError err); /** - * Checks if two DNSSECQuerys contain equal inner contents. + * Utility method to constructs a new OnPath-variant PathFailure + */ +struct LDKPathFailure PathFailure_on_path(struct LDKCOption_NetworkUpdateZ network_update); + +/** + * Checks if two PathFailures contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. */ -bool DNSSECQuery_eq(const struct LDKDNSSECQuery *NONNULL_PTR a, const struct LDKDNSSECQuery *NONNULL_PTR b); +bool PathFailure_eq(const struct LDKPathFailure *NONNULL_PTR a, const struct LDKPathFailure *NONNULL_PTR b); /** - * Frees any resources used by the DNSSECProof, if is_owned is set and inner is non-NULL. + * Serialize the PathFailure object into a byte array which can be read by PathFailure_read */ -void DNSSECProof_free(struct LDKDNSSECProof this_obj); +struct LDKCVec_u8Z PathFailure_write(const struct LDKPathFailure *NONNULL_PTR obj); /** - * An [RFC 9102 DNSSEC AuthenticationChain] providing a DNSSEC proof. - * - * [RFC 9102 DNSSEC AuthenticationChain]: https://www.rfc-editor.org/rfc/rfc9102.html#name-dnssec-authentication-chain - * - * Returns a copy of the field. + * Read a PathFailure from a byte array, created by PathFailure_write */ -struct LDKCVec_u8Z DNSSECProof_get_proof(const struct LDKDNSSECProof *NONNULL_PTR this_ptr); +struct LDKCResult_COption_PathFailureZDecodeErrorZ PathFailure_read(struct LDKu8slice ser); /** - * An [RFC 9102 DNSSEC AuthenticationChain] providing a DNSSEC proof. - * - * [RFC 9102 DNSSEC AuthenticationChain]: https://www.rfc-editor.org/rfc/rfc9102.html#name-dnssec-authentication-chain + * Frees any resources used by the ClosureReason */ -void DNSSECProof_set_proof(struct LDKDNSSECProof *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +void ClosureReason_free(struct LDKClosureReason this_ptr); /** - * Creates a copy of the DNSSECProof + * Creates a copy of the ClosureReason */ -struct LDKDNSSECProof DNSSECProof_clone(const struct LDKDNSSECProof *NONNULL_PTR orig); +struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the DNSSECProof. + * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason */ -uint64_t DNSSECProof_hash(const struct LDKDNSSECProof *NONNULL_PTR o); +struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKUntrustedString peer_msg); /** - * Checks if two DNSSECProofs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new HolderForceClosed-variant ClosureReason */ -bool DNSSECProof_eq(const struct LDKDNSSECProof *NONNULL_PTR a, const struct LDKDNSSECProof *NONNULL_PTR b); +struct LDKClosureReason ClosureReason_holder_force_closed(struct LDKCOption_boolZ broadcasted_latest_txn); /** - * Returns whether `tlv_type` corresponds to a TLV record for DNS Resolvers. + * Utility method to constructs a new LegacyCooperativeClosure-variant ClosureReason */ -MUST_USE_RES bool DNSResolverMessage_is_known_type(uint64_t tlv_type); +struct LDKClosureReason ClosureReason_legacy_cooperative_closure(void); /** - * Serialize the DNSResolverMessage object into a byte array which can be read by DNSResolverMessage_read + * Utility method to constructs a new CounterpartyInitiatedCooperativeClosure-variant ClosureReason */ -struct LDKCVec_u8Z DNSResolverMessage_write(const struct LDKDNSResolverMessage *NONNULL_PTR obj); +struct LDKClosureReason ClosureReason_counterparty_initiated_cooperative_closure(void); /** - * Read a DNSResolverMessage from a byte array, created by DNSResolverMessage_write + * Utility method to constructs a new LocallyInitiatedCooperativeClosure-variant ClosureReason */ -struct LDKCResult_DNSResolverMessageDecodeErrorZ DNSResolverMessage_read(struct LDKu8slice ser, uint64_t arg); +struct LDKClosureReason ClosureReason_locally_initiated_cooperative_closure(void); /** - * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is + * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason */ -struct LDKOnionMessageContents DNSResolverMessage_as_OnionMessageContents(const struct LDKDNSResolverMessage *NONNULL_PTR this_arg); +struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); /** - * Frees any resources used by the HumanReadableName, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new FundingTimedOut-variant ClosureReason */ -void HumanReadableName_free(struct LDKHumanReadableName this_obj); +struct LDKClosureReason ClosureReason_funding_timed_out(void); /** - * Creates a copy of the HumanReadableName + * Utility method to constructs a new ProcessingError-variant ClosureReason */ -struct LDKHumanReadableName HumanReadableName_clone(const struct LDKHumanReadableName *NONNULL_PTR orig); +struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); /** - * Generates a non-cryptographic 64-bit hash of the HumanReadableName. + * Utility method to constructs a new DisconnectedPeer-variant ClosureReason */ -uint64_t HumanReadableName_hash(const struct LDKHumanReadableName *NONNULL_PTR o); +struct LDKClosureReason ClosureReason_disconnected_peer(void); /** - * Checks if two HumanReadableNames contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason */ -bool HumanReadableName_eq(const struct LDKHumanReadableName *NONNULL_PTR a, const struct LDKHumanReadableName *NONNULL_PTR b); +struct LDKClosureReason ClosureReason_outdated_channel_manager(void); /** - * Constructs a new [`HumanReadableName`] from the `user` and `domain` parts. See the - * struct-level documentation for more on the requirements on each. + * Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason */ -MUST_USE_RES struct LDKCResult_HumanReadableNameNoneZ HumanReadableName_new(struct LDKStr user, struct LDKStr domain); +struct LDKClosureReason ClosureReason_counterparty_coop_closed_unfunded_channel(void); /** - * Constructs a new [`HumanReadableName`] from the standard encoding - `user`@`domain`. - * - * If `user` includes the standard BIP 353 â‚¿ prefix it is automatically removed as required by - * BIP 353. + * Utility method to constructs a new FundingBatchClosure-variant ClosureReason */ -MUST_USE_RES struct LDKCResult_HumanReadableNameNoneZ HumanReadableName_from_encoded(struct LDKStr encoded); +struct LDKClosureReason ClosureReason_funding_batch_closure(void); /** - * Gets the `user` part of this Human Readable Name + * Utility method to constructs a new HTLCsTimedOut-variant ClosureReason */ -MUST_USE_RES struct LDKStr HumanReadableName_user(const struct LDKHumanReadableName *NONNULL_PTR this_arg); +struct LDKClosureReason ClosureReason_htlcs_timed_out(void); /** - * Gets the `domain` part of this Human Readable Name + * Utility method to constructs a new PeerFeerateTooLow-variant ClosureReason */ -MUST_USE_RES struct LDKStr HumanReadableName_domain(const struct LDKHumanReadableName *NONNULL_PTR this_arg); +struct LDKClosureReason ClosureReason_peer_feerate_too_low(uint32_t peer_feerate_sat_per_kw, uint32_t required_feerate_sat_per_kw); /** - * Serialize the HumanReadableName object into a byte array which can be read by HumanReadableName_read + * Checks if two ClosureReasons contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCVec_u8Z HumanReadableName_write(const struct LDKHumanReadableName *NONNULL_PTR obj); +bool ClosureReason_eq(const struct LDKClosureReason *NONNULL_PTR a, const struct LDKClosureReason *NONNULL_PTR b); /** - * Read a HumanReadableName from a byte array, created by HumanReadableName_write + * Get the string representation of a ClosureReason object */ -struct LDKCResult_HumanReadableNameDecodeErrorZ HumanReadableName_read(struct LDKu8slice ser); +struct LDKStr ClosureReason_to_str(const struct LDKClosureReason *NONNULL_PTR o); /** - * Frees any resources used by the OMNameResolver, if is_owned is set and inner is non-NULL. + * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read */ -void OMNameResolver_free(struct LDKOMNameResolver this_obj); +struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); /** - * Builds a new [`OMNameResolver`]. + * Read a ClosureReason from a byte array, created by ClosureReason_write */ -MUST_USE_RES struct LDKOMNameResolver OMNameResolver_new(uint32_t latest_block_time, uint32_t latest_block_height); +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser); /** - * Informs the [`OMNameResolver`] of the passage of time in the form of a new best Bitcoin - * block. - * - * This will call back to resolve some pending queries which have timed out. + * Frees any resources used by the HTLCDestination */ -void OMNameResolver_new_best_block(const struct LDKOMNameResolver *NONNULL_PTR this_arg, uint32_t height, uint32_t time); +void HTLCDestination_free(struct LDKHTLCDestination this_ptr); /** - * Begins the process of resolving a BIP 353 Human Readable Name. - * - * Returns a [`DNSSECQuery`] onion message and a [`DNSResolverContext`] which should be sent - * to a resolver (with the context used to generate the blinded response path) on success. + * Creates a copy of the HTLCDestination */ -MUST_USE_RES struct LDKCResult_C2Tuple_DNSSECQueryDNSResolverContextZNoneZ OMNameResolver_resolve_name(const struct LDKOMNameResolver *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id, struct LDKHumanReadableName name, const struct LDKEntropySource *NONNULL_PTR entropy_source); +struct LDKHTLCDestination HTLCDestination_clone(const struct LDKHTLCDestination *NONNULL_PTR orig); /** - * Handles a [`DNSSECProof`] message, attempting to verify it and match it against a pending - * query. - * - * If verification succeeds, the resulting bitcoin: URI is parsed to find a contained - * [`Offer`]. - * - * Note that a single proof for a wildcard DNS entry may complete several requests for - * different [`HumanReadableName`]s. - * - * If an [`Offer`] is found, it, as well as the [`PaymentId`] and original `name` passed to - * [`Self::resolve_name`] are returned. + * Utility method to constructs a new NextHopChannel-variant HTLCDestination */ -MUST_USE_RES struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZOfferZZ OMNameResolver_handle_dnssec_proof_for_offer(const struct LDKOMNameResolver *NONNULL_PTR this_arg, struct LDKDNSSECProof msg, struct LDKDNSResolverContext context); +struct LDKHTLCDestination HTLCDestination_next_hop_channel(struct LDKPublicKey node_id, struct LDKChannelId channel_id); /** - * Handles a [`DNSSECProof`] message, attempting to verify it and match it against any pending - * queries. - * - * If verification succeeds, all matching [`PaymentId`] and [`HumanReadableName`]s passed to - * [`Self::resolve_name`], as well as the resolved bitcoin: URI are returned. - * - * Note that a single proof for a wildcard DNS entry may complete several requests for - * different [`HumanReadableName`]s. - * - * This method is useful for those who handle bitcoin: URIs already, handling more than just - * BOLT12 [`Offer`]s. + * Utility method to constructs a new UnknownNextHop-variant HTLCDestination */ -MUST_USE_RES struct LDKCOption_C2Tuple_CVec_C2Tuple_HumanReadableNameThirtyTwoBytesZZStrZZ OMNameResolver_handle_dnssec_proof_for_uri(const struct LDKOMNameResolver *NONNULL_PTR this_arg, struct LDKDNSSECProof msg, struct LDKDNSResolverContext context); +struct LDKHTLCDestination HTLCDestination_unknown_next_hop(uint64_t requested_forward_scid); /** - * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new InvalidForward-variant HTLCDestination */ -void OnionMessenger_free(struct LDKOnionMessenger this_obj); +struct LDKHTLCDestination HTLCDestination_invalid_forward(uint64_t requested_forward_scid); /** - * Frees any resources used by the Responder, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new InvalidOnion-variant HTLCDestination */ -void Responder_free(struct LDKResponder this_obj); +struct LDKHTLCDestination HTLCDestination_invalid_onion(void); /** - * Creates a copy of the Responder + * Utility method to constructs a new FailedPayment-variant HTLCDestination */ -struct LDKResponder Responder_clone(const struct LDKResponder *NONNULL_PTR orig); +struct LDKHTLCDestination HTLCDestination_failed_payment(struct LDKThirtyTwoBytes payment_hash); /** - * Checks if two Responders contain equal inner contents. + * Checks if two HTLCDestinations contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. */ -bool Responder_eq(const struct LDKResponder *NONNULL_PTR a, const struct LDKResponder *NONNULL_PTR b); +bool HTLCDestination_eq(const struct LDKHTLCDestination *NONNULL_PTR a, const struct LDKHTLCDestination *NONNULL_PTR b); /** - * Serialize the Responder object into a byte array which can be read by Responder_read + * Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read */ -struct LDKCVec_u8Z Responder_write(const struct LDKResponder *NONNULL_PTR obj); +struct LDKCVec_u8Z HTLCDestination_write(const struct LDKHTLCDestination *NONNULL_PTR obj); /** - * Read a Responder from a byte array, created by Responder_write + * Read a HTLCDestination from a byte array, created by HTLCDestination_write */ -struct LDKCResult_ResponderDecodeErrorZ Responder_read(struct LDKu8slice ser); +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(struct LDKu8slice ser); + +/** + * Creates a copy of the PaymentFailureReason + */ +enum LDKPaymentFailureReason PaymentFailureReason_clone(const enum LDKPaymentFailureReason *NONNULL_PTR orig); /** - * Creates a [`ResponseInstruction`] for responding without including a reply path. - * - * Use when the recipient doesn't need to send back a reply to us. + * Utility method to constructs a new RecipientRejected-variant PaymentFailureReason */ -MUST_USE_RES struct LDKResponseInstruction Responder_respond(struct LDKResponder this_arg); +enum LDKPaymentFailureReason PaymentFailureReason_recipient_rejected(void); /** - * Creates a [`ResponseInstruction`] for responding including a reply path. - * - * Use when the recipient needs to send back a reply to us. + * Utility method to constructs a new UserAbandoned-variant PaymentFailureReason */ -MUST_USE_RES struct LDKResponseInstruction Responder_respond_with_reply_path(struct LDKResponder this_arg, struct LDKMessageContext context); +enum LDKPaymentFailureReason PaymentFailureReason_user_abandoned(void); /** - * Frees any resources used by the ResponseInstruction, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason */ -void ResponseInstruction_free(struct LDKResponseInstruction this_obj); +enum LDKPaymentFailureReason PaymentFailureReason_retries_exhausted(void); /** - * Creates a copy of the ResponseInstruction + * Utility method to constructs a new PaymentExpired-variant PaymentFailureReason */ -struct LDKResponseInstruction ResponseInstruction_clone(const struct LDKResponseInstruction *NONNULL_PTR orig); +enum LDKPaymentFailureReason PaymentFailureReason_payment_expired(void); /** - * Converts this [`ResponseInstruction`] into a [`MessageSendInstructions`] so that it can be - * used to send the response via a normal message sending method. + * Utility method to constructs a new RouteNotFound-variant PaymentFailureReason */ -MUST_USE_RES struct LDKMessageSendInstructions ResponseInstruction_into_instructions(struct LDKResponseInstruction this_arg); +enum LDKPaymentFailureReason PaymentFailureReason_route_not_found(void); /** - * Frees any resources used by the MessageSendInstructions + * Utility method to constructs a new UnexpectedError-variant PaymentFailureReason */ -void MessageSendInstructions_free(struct LDKMessageSendInstructions this_ptr); +enum LDKPaymentFailureReason PaymentFailureReason_unexpected_error(void); /** - * Creates a copy of the MessageSendInstructions + * Utility method to constructs a new UnknownRequiredFeatures-variant PaymentFailureReason */ -struct LDKMessageSendInstructions MessageSendInstructions_clone(const struct LDKMessageSendInstructions *NONNULL_PTR orig); +enum LDKPaymentFailureReason PaymentFailureReason_unknown_required_features(void); /** - * Utility method to constructs a new WithSpecifiedReplyPath-variant MessageSendInstructions + * Utility method to constructs a new InvoiceRequestExpired-variant PaymentFailureReason */ -struct LDKMessageSendInstructions MessageSendInstructions_with_specified_reply_path(struct LDKDestination destination, struct LDKBlindedMessagePath reply_path); +enum LDKPaymentFailureReason PaymentFailureReason_invoice_request_expired(void); /** - * Utility method to constructs a new WithReplyPath-variant MessageSendInstructions + * Utility method to constructs a new InvoiceRequestRejected-variant PaymentFailureReason */ -struct LDKMessageSendInstructions MessageSendInstructions_with_reply_path(struct LDKDestination destination, struct LDKMessageContext context); +enum LDKPaymentFailureReason PaymentFailureReason_invoice_request_rejected(void); /** - * Utility method to constructs a new WithoutReplyPath-variant MessageSendInstructions + * Utility method to constructs a new BlindedPathCreationFailed-variant PaymentFailureReason */ -struct LDKMessageSendInstructions MessageSendInstructions_without_reply_path(struct LDKDestination destination); +enum LDKPaymentFailureReason PaymentFailureReason_blinded_path_creation_failed(void); /** - * Utility method to constructs a new ForReply-variant MessageSendInstructions + * Checks if two PaymentFailureReasons contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKMessageSendInstructions MessageSendInstructions_for_reply(struct LDKResponseInstruction instructions); +bool PaymentFailureReason_eq(const enum LDKPaymentFailureReason *NONNULL_PTR a, const enum LDKPaymentFailureReason *NONNULL_PTR b); /** - * Calls the free function if one is set + * Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read */ -void MessageRouter_free(struct LDKMessageRouter this_ptr); +struct LDKCVec_u8Z PaymentFailureReason_write(const enum LDKPaymentFailureReason *NONNULL_PTR obj); /** - * Frees any resources used by the DefaultMessageRouter, if is_owned is set and inner is non-NULL. + * Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write */ -void DefaultMessageRouter_free(struct LDKDefaultMessageRouter this_obj); +struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ PaymentFailureReason_read(struct LDKu8slice ser); /** - * Creates a [`DefaultMessageRouter`] using the given [`NetworkGraph`]. + * Frees any resources used by the InboundChannelFunds */ -MUST_USE_RES struct LDKDefaultMessageRouter DefaultMessageRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKEntropySource entropy_source); +void InboundChannelFunds_free(struct LDKInboundChannelFunds this_ptr); /** - * Constructs a new MessageRouter which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageRouter must be freed before this_arg is + * Creates a copy of the InboundChannelFunds */ -struct LDKMessageRouter DefaultMessageRouter_as_MessageRouter(const struct LDKDefaultMessageRouter *NONNULL_PTR this_arg); +struct LDKInboundChannelFunds InboundChannelFunds_clone(const struct LDKInboundChannelFunds *NONNULL_PTR orig); /** - * Frees any resources used by the OnionMessagePath, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new PushMsat-variant InboundChannelFunds */ -void OnionMessagePath_free(struct LDKOnionMessagePath this_obj); +struct LDKInboundChannelFunds InboundChannelFunds_push_msat(uint64_t a); /** - * Nodes on the path between the sender and the destination. - * - * Returns a copy of the field. + * Utility method to constructs a new DualFunded-variant InboundChannelFunds */ -struct LDKCVec_PublicKeyZ OnionMessagePath_get_intermediate_nodes(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); +struct LDKInboundChannelFunds InboundChannelFunds_dual_funded(void); /** - * Nodes on the path between the sender and the destination. + * Checks if two InboundChannelFundss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void OnionMessagePath_set_intermediate_nodes(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCVec_PublicKeyZ val); +bool InboundChannelFunds_eq(const struct LDKInboundChannelFunds *NONNULL_PTR a, const struct LDKInboundChannelFunds *NONNULL_PTR b); /** - * The recipient of the message. + * Frees any resources used by the Event */ -struct LDKDestination OnionMessagePath_get_destination(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); +void Event_free(struct LDKEvent this_ptr); /** - * The recipient of the message. + * Creates a copy of the Event */ -void OnionMessagePath_set_destination(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKDestination val); +struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); /** - * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. - * - * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use - * this to initiate such a connection. - * - * Returns a copy of the field. + * Utility method to constructs a new FundingGenerationReady-variant Event */ -struct LDKCOption_CVec_SocketAddressZZ OnionMessagePath_get_first_node_addresses(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); +struct LDKEvent Event_funding_generation_ready(struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t channel_value_satoshis, struct LDKCVec_u8Z output_script, struct LDKU128 user_channel_id); /** - * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. - * - * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use - * this to initiate such a connection. + * Utility method to constructs a new FundingTxBroadcastSafe-variant Event */ -void OnionMessagePath_set_first_node_addresses(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCOption_CVec_SocketAddressZZ val); +struct LDKEvent Event_funding_tx_broadcast_safe(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKOutPoint funding_txo, struct LDKPublicKey counterparty_node_id, struct LDKChannelId former_temporary_channel_id); /** - * Constructs a new OnionMessagePath given each field + * Utility method to constructs a new PaymentClaimable-variant Event */ -MUST_USE_RES struct LDKOnionMessagePath OnionMessagePath_new(struct LDKCVec_PublicKeyZ intermediate_nodes_arg, struct LDKDestination destination_arg, struct LDKCOption_CVec_SocketAddressZZ first_node_addresses_arg); +struct LDKEvent Event_payment_claimable(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields onion_fields, uint64_t amount_msat, uint64_t counterparty_skimmed_fee_msat, struct LDKPaymentPurpose purpose, struct LDKChannelId via_channel_id, struct LDKCOption_U128Z via_user_channel_id, struct LDKCOption_u32Z claim_deadline, struct LDKCOption_ThirtyTwoBytesZ payment_id); /** - * Creates a copy of the OnionMessagePath + * Utility method to constructs a new PaymentClaimed-variant Event */ -struct LDKOnionMessagePath OnionMessagePath_clone(const struct LDKOnionMessagePath *NONNULL_PTR orig); +struct LDKEvent Event_payment_claimed(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, uint64_t amount_msat, struct LDKPaymentPurpose purpose, struct LDKCVec_ClaimedHTLCZ htlcs, struct LDKCOption_u64Z sender_intended_total_msat, struct LDKRecipientOnionFields onion_fields, struct LDKCOption_ThirtyTwoBytesZ payment_id); /** - * Returns the first node in the path. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new ConnectionNeeded-variant Event */ -MUST_USE_RES struct LDKPublicKey OnionMessagePath_first_node(const struct LDKOnionMessagePath *NONNULL_PTR this_arg); +struct LDKEvent Event_connection_needed(struct LDKPublicKey node_id, struct LDKCVec_SocketAddressZ addresses); /** - * Frees any resources used by the Destination + * Utility method to constructs a new InvoiceReceived-variant Event */ -void Destination_free(struct LDKDestination this_ptr); +struct LDKEvent Event_invoice_received(struct LDKThirtyTwoBytes payment_id, struct LDKBolt12Invoice invoice, struct LDKCOption_OffersContextZ context, struct LDKResponder responder); /** - * Creates a copy of the Destination + * Utility method to constructs a new PaymentSent-variant Event */ -struct LDKDestination Destination_clone(const struct LDKDestination *NONNULL_PTR orig); +struct LDKEvent Event_payment_sent(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); /** - * Utility method to constructs a new Node-variant Destination + * Utility method to constructs a new PaymentFailed-variant Event */ -struct LDKDestination Destination_node(struct LDKPublicKey a); +struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKCOption_PaymentFailureReasonZ reason); /** - * Utility method to constructs a new BlindedPath-variant Destination + * Utility method to constructs a new PaymentPathSuccessful-variant Event */ -struct LDKDestination Destination_blinded_path(struct LDKBlindedMessagePath a); +struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKPath path); /** - * Generates a non-cryptographic 64-bit hash of the Destination. + * Utility method to constructs a new PaymentPathFailed-variant Event */ -uint64_t Destination_hash(const struct LDKDestination *NONNULL_PTR o); +struct LDKEvent Event_payment_path_failed(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKPathFailure failure, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); /** - * Checks if two Destinations contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Utility method to constructs a new ProbeSuccessful-variant Event */ -bool Destination_eq(const struct LDKDestination *NONNULL_PTR a, const struct LDKDestination *NONNULL_PTR b); +struct LDKEvent Event_probe_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path); /** - * Attempts to resolve the [`IntroductionNode::DirectedShortChannelId`] of a - * [`Destination::BlindedPath`] to a [`IntroductionNode::NodeId`], if applicable, using the - * provided [`ReadOnlyNetworkGraph`]. + * Utility method to constructs a new ProbeFailed-variant Event */ -void Destination_resolve(struct LDKDestination *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); +struct LDKEvent Event_probe_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); /** - * Frees any resources used by the SendSuccess + * Utility method to constructs a new PendingHTLCsForwardable-variant Event */ -void SendSuccess_free(struct LDKSendSuccess this_ptr); +struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); /** - * Creates a copy of the SendSuccess + * Utility method to constructs a new HTLCIntercepted-variant Event */ -struct LDKSendSuccess SendSuccess_clone(const struct LDKSendSuccess *NONNULL_PTR orig); +struct LDKEvent Event_htlcintercepted(struct LDKThirtyTwoBytes intercept_id, uint64_t requested_next_hop_scid, struct LDKThirtyTwoBytes payment_hash, uint64_t inbound_amount_msat, uint64_t expected_outbound_amount_msat); /** - * Utility method to constructs a new Buffered-variant SendSuccess + * Utility method to constructs a new SpendableOutputs-variant Event */ -struct LDKSendSuccess SendSuccess_buffered(void); +struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs, struct LDKChannelId channel_id); /** - * Utility method to constructs a new BufferedAwaitingConnection-variant SendSuccess + * Utility method to constructs a new PaymentForwarded-variant Event */ -struct LDKSendSuccess SendSuccess_buffered_awaiting_connection(struct LDKPublicKey a); +struct LDKEvent Event_payment_forwarded(struct LDKChannelId prev_channel_id, struct LDKChannelId next_channel_id, struct LDKCOption_U128Z prev_user_channel_id, struct LDKCOption_U128Z next_user_channel_id, struct LDKPublicKey prev_node_id, struct LDKPublicKey next_node_id, struct LDKCOption_u64Z total_fee_earned_msat, struct LDKCOption_u64Z skimmed_fee_msat, bool claim_from_onchain_tx, struct LDKCOption_u64Z outbound_amount_forwarded_msat); /** - * Generates a non-cryptographic 64-bit hash of the SendSuccess. + * Utility method to constructs a new ChannelPending-variant Event */ -uint64_t SendSuccess_hash(const struct LDKSendSuccess *NONNULL_PTR o); +struct LDKEvent Event_channel_pending(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKChannelId former_temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKOutPoint funding_txo, struct LDKChannelTypeFeatures channel_type); /** - * Checks if two SendSuccesss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Utility method to constructs a new ChannelReady-variant Event */ -bool SendSuccess_eq(const struct LDKSendSuccess *NONNULL_PTR a, const struct LDKSendSuccess *NONNULL_PTR b); +struct LDKEvent Event_channel_ready(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKChannelTypeFeatures channel_type); /** - * Frees any resources used by the SendError + * Utility method to constructs a new ChannelClosed-variant Event */ -void SendError_free(struct LDKSendError this_ptr); +struct LDKEvent Event_channel_closed(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKClosureReason reason, struct LDKPublicKey counterparty_node_id, struct LDKCOption_u64Z channel_capacity_sats, struct LDKOutPoint channel_funding_txo, struct LDKCOption_u64Z last_local_balance_msat); /** - * Creates a copy of the SendError + * Utility method to constructs a new DiscardFunding-variant Event */ -struct LDKSendError SendError_clone(const struct LDKSendError *NONNULL_PTR orig); +struct LDKEvent Event_discard_funding(struct LDKChannelId channel_id, struct LDKFundingInfo funding_info); /** - * Utility method to constructs a new Secp256k1-variant SendError + * Utility method to constructs a new OpenChannelRequest-variant Event */ -struct LDKSendError SendError_secp256k1(enum LDKSecp256k1Error a); +struct LDKEvent Event_open_channel_request(struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, struct LDKInboundChannelFunds channel_negotiation_type, struct LDKChannelTypeFeatures channel_type, bool is_announced, struct LDKChannelParameters params); /** - * Utility method to constructs a new TooBigPacket-variant SendError + * Utility method to constructs a new HTLCHandlingFailed-variant Event */ -struct LDKSendError SendError_too_big_packet(void); +struct LDKEvent Event_htlchandling_failed(struct LDKChannelId prev_channel_id, struct LDKHTLCDestination failed_next_destination); /** - * Utility method to constructs a new TooFewBlindedHops-variant SendError + * Utility method to constructs a new BumpTransaction-variant Event */ -struct LDKSendError SendError_too_few_blinded_hops(void); +struct LDKEvent Event_bump_transaction(struct LDKBumpTransactionEvent a); /** - * Utility method to constructs a new InvalidFirstHop-variant SendError + * Utility method to constructs a new OnionMessageIntercepted-variant Event */ -struct LDKSendError SendError_invalid_first_hop(struct LDKPublicKey a); +struct LDKEvent Event_onion_message_intercepted(struct LDKPublicKey peer_node_id, struct LDKOnionMessage message); /** - * Utility method to constructs a new PathNotFound-variant SendError + * Utility method to constructs a new OnionMessagePeerConnected-variant Event */ -struct LDKSendError SendError_path_not_found(void); +struct LDKEvent Event_onion_message_peer_connected(struct LDKPublicKey peer_node_id); /** - * Utility method to constructs a new InvalidMessage-variant SendError + * Checks if two Events contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKSendError SendError_invalid_message(void); +bool Event_eq(const struct LDKEvent *NONNULL_PTR a, const struct LDKEvent *NONNULL_PTR b); /** - * Utility method to constructs a new BufferFull-variant SendError + * Serialize the Event object into a byte array which can be read by Event_read */ -struct LDKSendError SendError_buffer_full(void); +struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); /** - * Utility method to constructs a new GetNodeIdFailed-variant SendError + * Read a Event from a byte array, created by Event_write */ -struct LDKSendError SendError_get_node_id_failed(void); +struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser); /** - * Utility method to constructs a new UnresolvedIntroductionNode-variant SendError + * Frees any resources used by the MessageSendEvent */ -struct LDKSendError SendError_unresolved_introduction_node(void); +void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); /** - * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError + * Creates a copy of the MessageSendEvent */ -struct LDKSendError SendError_blinded_path_advance_failed(void); +struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the SendError. + * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent */ -uint64_t SendError_hash(const struct LDKSendError *NONNULL_PTR o); +struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg); /** - * Checks if two SendErrors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Utility method to constructs a new SendAcceptChannelV2-variant MessageSendEvent */ -bool SendError_eq(const struct LDKSendError *NONNULL_PTR a, const struct LDKSendError *NONNULL_PTR b); +struct LDKMessageSendEvent MessageSendEvent_send_accept_channel_v2(struct LDKPublicKey node_id, struct LDKAcceptChannelV2 msg); /** - * Calls the free function if one is set + * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent */ -void CustomOnionMessageHandler_free(struct LDKCustomOnionMessageHandler this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg); /** - * Frees any resources used by the PeeledOnion + * Utility method to constructs a new SendOpenChannelV2-variant MessageSendEvent */ -void PeeledOnion_free(struct LDKPeeledOnion this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_open_channel_v2(struct LDKPublicKey node_id, struct LDKOpenChannelV2 msg); /** - * Creates a copy of the PeeledOnion + * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent */ -struct LDKPeeledOnion PeeledOnion_clone(const struct LDKPeeledOnion *NONNULL_PTR orig); +struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg); /** - * Utility method to constructs a new Forward-variant PeeledOnion + * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent */ -struct LDKPeeledOnion PeeledOnion_forward(struct LDKNextMessageHop a, struct LDKOnionMessage b); +struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg); /** - * Utility method to constructs a new Receive-variant PeeledOnion + * Utility method to constructs a new SendStfu-variant MessageSendEvent */ -struct LDKPeeledOnion PeeledOnion_receive(struct LDKParsedOnionMessageContents a, struct LDKCOption_MessageContextZ b, struct LDKBlindedMessagePath c); +struct LDKMessageSendEvent MessageSendEvent_send_stfu(struct LDKPublicKey node_id, struct LDKStfu msg); /** - * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of - * `path`, first calling [`Destination::resolve`] on `path.destination` with the given - * [`ReadOnlyNetworkGraph`]. - * - * Returns the node id of the peer to send the message to, the message itself, and any addresses - * needed to connect to the first node. - * - * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new SendSpliceInit-variant MessageSendEvent */ -struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message_resolving_destination(const struct LDKEntropySource *NONNULL_PTR entropy_source, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph, struct LDKOnionMessagePath path, struct LDKOnionMessageContents contents, struct LDKBlindedMessagePath reply_path); +struct LDKMessageSendEvent MessageSendEvent_send_splice_init(struct LDKPublicKey node_id, struct LDKSpliceInit msg); /** - * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of - * `path`. - * - * Returns the node id of the peer to send the message to, the message itself, and any addresses - * needed to connect to the first node. - * - * Returns [`SendError::UnresolvedIntroductionNode`] if: - * - `destination` contains a blinded path with an [`IntroductionNode::DirectedShortChannelId`], - * - unless it can be resolved by [`NodeIdLookUp::next_node_id`]. - * Use [`create_onion_message_resolving_destination`] instead to resolve the introduction node - * first with a [`ReadOnlyNetworkGraph`]. - * - * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new SendSpliceAck-variant MessageSendEvent */ -struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message(const struct LDKEntropySource *NONNULL_PTR entropy_source, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup, struct LDKOnionMessagePath path, struct LDKOnionMessageContents contents, struct LDKBlindedMessagePath reply_path); +struct LDKMessageSendEvent MessageSendEvent_send_splice_ack(struct LDKPublicKey node_id, struct LDKSpliceAck msg); /** - * Decode one layer of an incoming [`OnionMessage`]. - * - * Returns either the next layer of the onion for forwarding or the decrypted content for the - * receiver. + * Utility method to constructs a new SendSpliceLocked-variant MessageSendEvent */ -struct LDKCResult_PeeledOnionNoneZ peel_onion_message(const struct LDKOnionMessage *NONNULL_PTR msg, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler); +struct LDKMessageSendEvent MessageSendEvent_send_splice_locked(struct LDKPublicKey node_id, struct LDKSpliceLocked msg); /** - * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to - * their respective handlers. + * Utility method to constructs a new SendTxAddInput-variant MessageSendEvent */ -MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKNodeIdLookUp node_id_lookup, struct LDKMessageRouter message_router, struct LDKOffersMessageHandler offers_handler, struct LDKAsyncPaymentsMessageHandler async_payments_handler, struct LDKDNSResolverMessageHandler dns_resolver, struct LDKCustomOnionMessageHandler custom_handler); +struct LDKMessageSendEvent MessageSendEvent_send_tx_add_input(struct LDKPublicKey node_id, struct LDKTxAddInput msg); /** - * Similar to [`Self::new`], but rather than dropping onion messages that are - * intended to be forwarded to offline peers, we will intercept them for - * later forwarding. - * - * Interception flow: - * 1. If an onion message for an offline peer is received, `OnionMessenger` will - * generate an [`Event::OnionMessageIntercepted`]. Event handlers can - * then choose to persist this onion message for later forwarding, or drop - * it. - * 2. When the offline peer later comes back online, `OnionMessenger` will - * generate an [`Event::OnionMessagePeerConnected`]. Event handlers will - * then fetch all previously intercepted onion messages for this peer. - * 3. Once the stored onion messages are fetched, they can finally be - * forwarded to the now-online peer via [`Self::forward_onion_message`]. - * - * # Note - * - * LDK will not rate limit how many [`Event::OnionMessageIntercepted`]s - * are generated, so it is the caller's responsibility to limit how many - * onion messages are persisted and only persist onion messages for relevant - * peers. + * Utility method to constructs a new SendTxAddOutput-variant MessageSendEvent */ -MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new_with_offline_peer_interception(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKNodeIdLookUp node_id_lookup, struct LDKMessageRouter message_router, struct LDKOffersMessageHandler offers_handler, struct LDKAsyncPaymentsMessageHandler async_payments_handler, struct LDKDNSResolverMessageHandler dns_resolver, struct LDKCustomOnionMessageHandler custom_handler); +struct LDKMessageSendEvent MessageSendEvent_send_tx_add_output(struct LDKPublicKey node_id, struct LDKTxAddOutput msg); /** - * Sends an [`OnionMessage`] based on its [`MessageSendInstructions`]. + * Utility method to constructs a new SendTxRemoveInput-variant MessageSendEvent */ -MUST_USE_RES struct LDKCResult_SendSuccessSendErrorZ OnionMessenger_send_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessageContents contents, struct LDKMessageSendInstructions instructions); +struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_input(struct LDKPublicKey node_id, struct LDKTxRemoveInput msg); /** - * Forwards an [`OnionMessage`] to `peer_node_id`. Useful if we initialized - * the [`OnionMessenger`] with [`Self::new_with_offline_peer_interception`] - * and want to forward a previously intercepted onion message to a peer that - * has just come online. + * Utility method to constructs a new SendTxRemoveOutput-variant MessageSendEvent */ -MUST_USE_RES struct LDKCResult_NoneSendErrorZ OnionMessenger_forward_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessage message, struct LDKPublicKey peer_node_id); +struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_output(struct LDKPublicKey node_id, struct LDKTxRemoveOutput msg); /** - * Handles the response to an [`OnionMessage`] based on its [`ResponseInstruction`], - * enqueueing any response for sending. - * - * This function is useful for asynchronous handling of [`OnionMessage`]s. - * Handlers have the option to return `None`, indicating that no immediate response should be - * sent. Then, they can transfer the associated [`Responder`] to another task responsible for - * generating the response asynchronously. Subsequently, when the response is prepared and - * ready for sending, that task can invoke this method to enqueue the response for delivery. + * Utility method to constructs a new SendTxComplete-variant MessageSendEvent */ -MUST_USE_RES struct LDKCResult_SendSuccessSendErrorZ OnionMessenger_handle_onion_message_response(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessageContents response, struct LDKResponseInstruction instructions); +struct LDKMessageSendEvent MessageSendEvent_send_tx_complete(struct LDKPublicKey node_id, struct LDKTxComplete msg); /** - * Gets a [`Future`] that completes when an event is available via - * [`EventsProvider::process_pending_events`] or [`Self::process_pending_events_async`]. - * - * Note that callbacks registered on the [`Future`] MUST NOT call back into this - * [`OnionMessenger`] and should instead register actions to be taken later. - * - * [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events + * Utility method to constructs a new SendTxSignatures-variant MessageSendEvent */ -MUST_USE_RES struct LDKFuture OnionMessenger_get_update_future(const struct LDKOnionMessenger *NONNULL_PTR this_arg); +struct LDKMessageSendEvent MessageSendEvent_send_tx_signatures(struct LDKPublicKey node_id, struct LDKTxSignatures msg); /** - * Constructs a new EventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + * Utility method to constructs a new SendTxInitRbf-variant MessageSendEvent */ -struct LDKEventsProvider OnionMessenger_as_EventsProvider(const struct LDKOnionMessenger *NONNULL_PTR this_arg); +struct LDKMessageSendEvent MessageSendEvent_send_tx_init_rbf(struct LDKPublicKey node_id, struct LDKTxInitRbf msg); /** - * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is + * Utility method to constructs a new SendTxAckRbf-variant MessageSendEvent */ -struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct LDKOnionMessenger *NONNULL_PTR this_arg); +struct LDKMessageSendEvent MessageSendEvent_send_tx_ack_rbf(struct LDKPublicKey node_id, struct LDKTxAckRbf msg); /** - * Calls the free function if one is set + * Utility method to constructs a new SendTxAbort-variant MessageSendEvent */ -void OffersMessageHandler_free(struct LDKOffersMessageHandler this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_tx_abort(struct LDKPublicKey node_id, struct LDKTxAbort msg); /** - * Frees any resources used by the OffersMessage + * Utility method to constructs a new SendChannelReady-variant MessageSendEvent */ -void OffersMessage_free(struct LDKOffersMessage this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_channel_ready(struct LDKPublicKey node_id, struct LDKChannelReady msg); /** - * Creates a copy of the OffersMessage + * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent */ -struct LDKOffersMessage OffersMessage_clone(const struct LDKOffersMessage *NONNULL_PTR orig); +struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg); /** - * Utility method to constructs a new InvoiceRequest-variant OffersMessage + * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent */ -struct LDKOffersMessage OffersMessage_invoice_request(struct LDKInvoiceRequest a); +struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates); /** - * Utility method to constructs a new Invoice-variant OffersMessage + * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent */ -struct LDKOffersMessage OffersMessage_invoice(struct LDKBolt12Invoice a); +struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg); /** - * Utility method to constructs a new InvoiceError-variant OffersMessage + * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent */ -struct LDKOffersMessage OffersMessage_invoice_error(struct LDKInvoiceError a); +struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg); /** - * Returns whether `tlv_type` corresponds to a TLV record for Offers. + * Utility method to constructs a new SendShutdown-variant MessageSendEvent */ -MUST_USE_RES bool OffersMessage_is_known_type(uint64_t tlv_type); +struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg); /** - * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is + * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent */ -struct LDKOnionMessageContents OffersMessage_as_OnionMessageContents(const struct LDKOffersMessage *NONNULL_PTR this_arg); +struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg); /** - * Serialize the OffersMessage object into a byte array which can be read by OffersMessage_read + * Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent */ -struct LDKCVec_u8Z OffersMessage_write(const struct LDKOffersMessage *NONNULL_PTR obj); +struct LDKMessageSendEvent MessageSendEvent_send_channel_announcement(struct LDKPublicKey node_id, struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); /** - * Read a OffersMessage from a byte array, created by OffersMessage_write + * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent */ -struct LDKCResult_OffersMessageDecodeErrorZ OffersMessage_read(struct LDKu8slice ser, uint64_t arg_a, const struct LDKLogger *NONNULL_PTR arg_b); +struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); /** - * Frees any resources used by the Packet, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent */ -void Packet_free(struct LDKPacket this_obj); +struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_update(struct LDKChannelUpdate msg); /** - * Bolt 04 version number + * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent */ -uint8_t Packet_get_version(const struct LDKPacket *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg); /** - * Bolt 04 version number + * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent */ -void Packet_set_version(struct LDKPacket *NONNULL_PTR this_ptr, uint8_t val); +struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublicKey node_id, struct LDKChannelUpdate msg); /** - * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data + * Utility method to constructs a new HandleError-variant MessageSendEvent */ -struct LDKPublicKey Packet_get_public_key(const struct LDKPacket *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action); /** - * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data + * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent */ -void Packet_set_public_key(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); /** - * Encrypted payload for the next hop - * - * Returns a copy of the field. + * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent */ -struct LDKCVec_u8Z Packet_get_hop_data(const struct LDKPacket *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg); /** - * Encrypted payload for the next hop + * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent */ -void Packet_set_hop_data(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg); /** - * HMAC to verify the integrity of hop_data + * Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent */ -const uint8_t (*Packet_get_hmac(const struct LDKPacket *NONNULL_PTR this_ptr))[32]; +struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct LDKPublicKey node_id, struct LDKGossipTimestampFilter msg); /** - * HMAC to verify the integrity of hop_data + * Calls the free function if one is set */ -void Packet_set_hmac(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); /** - * Constructs a new Packet given each field + * Calls the free function if one is set */ -MUST_USE_RES struct LDKPacket Packet_new(uint8_t version_arg, struct LDKPublicKey public_key_arg, struct LDKCVec_u8Z hop_data_arg, struct LDKThirtyTwoBytes hmac_arg); +void EventsProvider_free(struct LDKEventsProvider this_ptr); /** - * Creates a copy of the Packet + * Frees any resources used by the ReplayEvent, if is_owned is set and inner is non-NULL. */ -struct LDKPacket Packet_clone(const struct LDKPacket *NONNULL_PTR orig); +void ReplayEvent_free(struct LDKReplayEvent this_obj); /** - * Generates a non-cryptographic 64-bit hash of the Packet. + * Constructs a new ReplayEvent given each field */ -uint64_t Packet_hash(const struct LDKPacket *NONNULL_PTR o); +MUST_USE_RES struct LDKReplayEvent ReplayEvent_new(void); /** - * Checks if two Packets contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the ReplayEvent */ -bool Packet_eq(const struct LDKPacket *NONNULL_PTR a, const struct LDKPacket *NONNULL_PTR b); +struct LDKReplayEvent ReplayEvent_clone(const struct LDKReplayEvent *NONNULL_PTR orig); /** - * Serialize the Packet object into a byte array which can be read by Packet_read + * Calls the free function if one is set */ -struct LDKCVec_u8Z Packet_write(const struct LDKPacket *NONNULL_PTR obj); +void EventHandler_free(struct LDKEventHandler this_ptr); /** - * Frees any resources used by the ParsedOnionMessageContents + * Frees any resources used by the AnchorDescriptor, if is_owned is set and inner is non-NULL. */ -void ParsedOnionMessageContents_free(struct LDKParsedOnionMessageContents this_ptr); +void AnchorDescriptor_free(struct LDKAnchorDescriptor this_obj); /** - * Creates a copy of the ParsedOnionMessageContents + * The parameters required to derive the signer for the anchor input. */ -struct LDKParsedOnionMessageContents ParsedOnionMessageContents_clone(const struct LDKParsedOnionMessageContents *NONNULL_PTR orig); +struct LDKChannelDerivationParameters AnchorDescriptor_get_channel_derivation_parameters(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Offers-variant ParsedOnionMessageContents + * The parameters required to derive the signer for the anchor input. */ -struct LDKParsedOnionMessageContents ParsedOnionMessageContents_offers(struct LDKOffersMessage a); +void AnchorDescriptor_set_channel_derivation_parameters(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); /** - * Utility method to constructs a new DNSResolver-variant ParsedOnionMessageContents + * The transaction input's outpoint corresponding to the commitment transaction's anchor + * output. */ -struct LDKParsedOnionMessageContents ParsedOnionMessageContents_dnsresolver(struct LDKDNSResolverMessage a); +struct LDKOutPoint AnchorDescriptor_get_outpoint(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Custom-variant ParsedOnionMessageContents + * The transaction input's outpoint corresponding to the commitment transaction's anchor + * output. */ -struct LDKParsedOnionMessageContents ParsedOnionMessageContents_custom(struct LDKOnionMessageContents a); +void AnchorDescriptor_set_outpoint(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is + * Constructs a new AnchorDescriptor given each field */ -struct LDKOnionMessageContents ParsedOnionMessageContents_as_OnionMessageContents(const struct LDKParsedOnionMessageContents *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKAnchorDescriptor AnchorDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKOutPoint outpoint_arg); /** - * Serialize the ParsedOnionMessageContents object into a byte array which can be read by ParsedOnionMessageContents_read + * Creates a copy of the AnchorDescriptor */ -struct LDKCVec_u8Z ParsedOnionMessageContents_write(const struct LDKParsedOnionMessageContents *NONNULL_PTR obj); +struct LDKAnchorDescriptor AnchorDescriptor_clone(const struct LDKAnchorDescriptor *NONNULL_PTR orig); /** - * Creates a copy of a OnionMessageContents + * Checks if two AnchorDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKOnionMessageContents OnionMessageContents_clone(const struct LDKOnionMessageContents *NONNULL_PTR orig); +bool AnchorDescriptor_eq(const struct LDKAnchorDescriptor *NONNULL_PTR a, const struct LDKAnchorDescriptor *NONNULL_PTR b); /** - * Calls the free function if one is set + * Returns the UTXO to be spent by the anchor input, which can be obtained via + * [`Self::unsigned_tx_input`]. */ -void OnionMessageContents_free(struct LDKOnionMessageContents this_ptr); +MUST_USE_RES struct LDKTxOut AnchorDescriptor_previous_utxo(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); /** - * Frees any resources used by the IntroductionNode + * Returns the unsigned transaction input spending the anchor output in the commitment + * transaction. */ -void IntroductionNode_free(struct LDKIntroductionNode this_ptr); +MUST_USE_RES struct LDKTxIn AnchorDescriptor_unsigned_tx_input(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); /** - * Creates a copy of the IntroductionNode + * Returns the witness script of the anchor output in the commitment transaction. */ -struct LDKIntroductionNode IntroductionNode_clone(const struct LDKIntroductionNode *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_u8Z AnchorDescriptor_witness_script(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); /** - * Utility method to constructs a new NodeId-variant IntroductionNode + * Returns the fully signed witness required to spend the anchor output in the commitment + * transaction. */ -struct LDKIntroductionNode IntroductionNode_node_id(struct LDKPublicKey a); +MUST_USE_RES struct LDKWitness AnchorDescriptor_tx_input_witness(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature); /** - * Utility method to constructs a new DirectedShortChannelId-variant IntroductionNode + * Derives the channel signer required to sign the anchor input. */ -struct LDKIntroductionNode IntroductionNode_directed_short_channel_id(enum LDKDirection a, uint64_t b); +MUST_USE_RES struct LDKEcdsaChannelSigner AnchorDescriptor_derive_channel_signer(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); /** - * Generates a non-cryptographic 64-bit hash of the IntroductionNode. + * Frees any resources used by the BumpTransactionEvent */ -uint64_t IntroductionNode_hash(const struct LDKIntroductionNode *NONNULL_PTR o); +void BumpTransactionEvent_free(struct LDKBumpTransactionEvent this_ptr); /** - * Checks if two IntroductionNodes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Creates a copy of the BumpTransactionEvent */ -bool IntroductionNode_eq(const struct LDKIntroductionNode *NONNULL_PTR a, const struct LDKIntroductionNode *NONNULL_PTR b); +struct LDKBumpTransactionEvent BumpTransactionEvent_clone(const struct LDKBumpTransactionEvent *NONNULL_PTR orig); /** - * Creates a copy of the Direction + * Utility method to constructs a new ChannelClose-variant BumpTransactionEvent */ -enum LDKDirection Direction_clone(const enum LDKDirection *NONNULL_PTR orig); +struct LDKBumpTransactionEvent BumpTransactionEvent_channel_close(struct LDKChannelId channel_id, struct LDKPublicKey counterparty_node_id, struct LDKThirtyTwoBytes claim_id, uint32_t package_target_feerate_sat_per_1000_weight, struct LDKTransaction commitment_tx, uint64_t commitment_tx_fee_satoshis, struct LDKAnchorDescriptor anchor_descriptor, struct LDKCVec_HTLCOutputInCommitmentZ pending_htlcs); /** - * Utility method to constructs a new NodeOne-variant Direction + * Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent */ -enum LDKDirection Direction_node_one(void); +struct LDKBumpTransactionEvent BumpTransactionEvent_htlcresolution(struct LDKChannelId channel_id, struct LDKPublicKey counterparty_node_id, struct LDKThirtyTwoBytes claim_id, uint32_t target_feerate_sat_per_1000_weight, struct LDKCVec_HTLCDescriptorZ htlc_descriptors, uint32_t tx_lock_time); /** - * Utility method to constructs a new NodeTwo-variant Direction + * Checks if two BumpTransactionEvents contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -enum LDKDirection Direction_node_two(void); +bool BumpTransactionEvent_eq(const struct LDKBumpTransactionEvent *NONNULL_PTR a, const struct LDKBumpTransactionEvent *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the Direction. + * Frees any resources used by the Input, if is_owned is set and inner is non-NULL. */ -uint64_t Direction_hash(const enum LDKDirection *NONNULL_PTR o); +void Input_free(struct LDKInput this_obj); /** - * Checks if two Directions contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * The unique identifier of the input. */ -bool Direction_eq(const enum LDKDirection *NONNULL_PTR a, const enum LDKDirection *NONNULL_PTR b); +struct LDKOutPoint Input_get_outpoint(const struct LDKInput *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * The unique identifier of the input. */ -void NodeIdLookUp_free(struct LDKNodeIdLookUp this_ptr); +void Input_set_outpoint(struct LDKInput *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Frees any resources used by the EmptyNodeIdLookUp, if is_owned is set and inner is non-NULL. + * The UTXO being spent by the input. */ -void EmptyNodeIdLookUp_free(struct LDKEmptyNodeIdLookUp this_obj); +struct LDKTxOut Input_get_previous_utxo(const struct LDKInput *NONNULL_PTR this_ptr); /** - * Constructs a new EmptyNodeIdLookUp given each field + * The UTXO being spent by the input. */ -MUST_USE_RES struct LDKEmptyNodeIdLookUp EmptyNodeIdLookUp_new(void); +void Input_set_previous_utxo(struct LDKInput *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and + * [`TxIn::witness`], each with their lengths included, required to satisfy the output's + * script. */ -struct LDKNodeIdLookUp EmptyNodeIdLookUp_as_NodeIdLookUp(const struct LDKEmptyNodeIdLookUp *NONNULL_PTR this_arg); +uint64_t Input_get_satisfaction_weight(const struct LDKInput *NONNULL_PTR this_ptr); /** - * Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL. + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and + * [`TxIn::witness`], each with their lengths included, required to satisfy the output's + * script. */ -void BlindedHop_free(struct LDKBlindedHop this_obj); +void Input_set_satisfaction_weight(struct LDKInput *NONNULL_PTR this_ptr, uint64_t val); /** - * The blinded node id of this hop in a blinded path. + * Constructs a new Input given each field */ -struct LDKPublicKey BlindedHop_get_blinded_node_id(const struct LDKBlindedHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInput Input_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut previous_utxo_arg, uint64_t satisfaction_weight_arg); /** - * The blinded node id of this hop in a blinded path. + * Creates a copy of the Input */ -void BlindedHop_set_blinded_node_id(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKInput Input_clone(const struct LDKInput *NONNULL_PTR orig); /** - * The encrypted payload intended for this hop in a blinded path. - * - * Returns a copy of the field. + * Generates a non-cryptographic 64-bit hash of the Input. */ -struct LDKCVec_u8Z BlindedHop_get_encrypted_payload(const struct LDKBlindedHop *NONNULL_PTR this_ptr); +uint64_t Input_hash(const struct LDKInput *NONNULL_PTR o); /** - * The encrypted payload intended for this hop in a blinded path. + * Checks if two Inputs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void BlindedHop_set_encrypted_payload(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +bool Input_eq(const struct LDKInput *NONNULL_PTR a, const struct LDKInput *NONNULL_PTR b); /** - * Constructs a new BlindedHop given each field + * Frees any resources used by the Utxo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKBlindedHop BlindedHop_new(struct LDKPublicKey blinded_node_id_arg, struct LDKCVec_u8Z encrypted_payload_arg); +void Utxo_free(struct LDKUtxo this_obj); /** - * Creates a copy of the BlindedHop + * The unique identifier of the output. */ -struct LDKBlindedHop BlindedHop_clone(const struct LDKBlindedHop *NONNULL_PTR orig); +struct LDKOutPoint Utxo_get_outpoint(const struct LDKUtxo *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the BlindedHop. + * The unique identifier of the output. */ -uint64_t BlindedHop_hash(const struct LDKBlindedHop *NONNULL_PTR o); +void Utxo_set_outpoint(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Checks if two BlindedHops contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The output to spend. */ -bool BlindedHop_eq(const struct LDKBlindedHop *NONNULL_PTR a, const struct LDKBlindedHop *NONNULL_PTR b); +struct LDKTxOut Utxo_get_output(const struct LDKUtxo *NONNULL_PTR this_ptr); /** - * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read + * The output to spend. */ -struct LDKCVec_u8Z BlindedHop_write(const struct LDKBlindedHop *NONNULL_PTR obj); +void Utxo_set_output(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Read a BlindedHop from a byte array, created by BlindedHop_write + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each + * with their lengths included, required to satisfy the output's script. The weight consumed by + * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. */ -struct LDKCResult_BlindedHopDecodeErrorZ BlindedHop_read(struct LDKu8slice ser); +uint64_t Utxo_get_satisfaction_weight(const struct LDKUtxo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each + * with their lengths included, required to satisfy the output's script. The weight consumed by + * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. */ -void BlindedPayInfo_free(struct LDKBlindedPayInfo this_obj); +void Utxo_set_satisfaction_weight(struct LDKUtxo *NONNULL_PTR this_ptr, uint64_t val); /** - * Base fee charged (in millisatoshi) for the entire blinded path. + * Constructs a new Utxo given each field */ -uint32_t BlindedPayInfo_get_fee_base_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKUtxo Utxo_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, uint64_t satisfaction_weight_arg); /** - * Base fee charged (in millisatoshi) for the entire blinded path. + * Creates a copy of the Utxo */ -void BlindedPayInfo_set_fee_base_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKUtxo Utxo_clone(const struct LDKUtxo *NONNULL_PTR orig); /** - * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path - * (i.e., 10,000 is 1%). + * Generates a non-cryptographic 64-bit hash of the Utxo. */ -uint32_t BlindedPayInfo_get_fee_proportional_millionths(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +uint64_t Utxo_hash(const struct LDKUtxo *NONNULL_PTR o); /** - * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path - * (i.e., 10,000 is 1%). + * Checks if two Utxos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void BlindedPayInfo_set_fee_proportional_millionths(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); +bool Utxo_eq(const struct LDKUtxo *NONNULL_PTR a, const struct LDKUtxo *NONNULL_PTR b); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded - * path. + * Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output. */ -uint16_t BlindedPayInfo_get_cltv_expiry_delta(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKUtxo Utxo_new_p2pkh(struct LDKOutPoint outpoint, uint64_t value, const uint8_t (*pubkey_hash)[20]); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded - * path. + * Frees any resources used by the CoinSelection, if is_owned is set and inner is non-NULL. */ -void BlindedPayInfo_set_cltv_expiry_delta(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint16_t val); +void CoinSelection_free(struct LDKCoinSelection this_obj); /** - * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction + * requiring additional fees. */ -uint64_t BlindedPayInfo_get_htlc_minimum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +struct LDKCVec_UtxoZ CoinSelection_get_confirmed_utxos(const struct LDKCoinSelection *NONNULL_PTR this_ptr); /** - * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction + * requiring additional fees. */ -void BlindedPayInfo_set_htlc_minimum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); +void CoinSelection_set_confirmed_utxos(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCVec_UtxoZ val); /** - * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * An additional output tracking whether any change remained after coin selection. This output + * should always have a value above dust for its given `script_pubkey`. It should not be + * spent until the transaction it belongs to confirms to ensure mempool descendant limits are + * not met. This implies no other party should be able to spend it except us. */ -uint64_t BlindedPayInfo_get_htlc_maximum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +struct LDKCOption_TxOutZ CoinSelection_get_change_output(const struct LDKCoinSelection *NONNULL_PTR this_ptr); /** - * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * An additional output tracking whether any change remained after coin selection. This output + * should always have a value above dust for its given `script_pubkey`. It should not be + * spent until the transaction it belongs to confirms to ensure mempool descendant limits are + * not met. This implies no other party should be able to spend it except us. */ -void BlindedPayInfo_set_htlc_maximum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); +void CoinSelection_set_change_output(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCOption_TxOutZ val); /** - * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an - * onion payload. + * Constructs a new CoinSelection given each field */ -struct LDKBlindedHopFeatures BlindedPayInfo_get_features(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCoinSelection CoinSelection_new(struct LDKCVec_UtxoZ confirmed_utxos_arg, struct LDKCOption_TxOutZ change_output_arg); /** - * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an - * onion payload. + * Creates a copy of the CoinSelection */ -void BlindedPayInfo_set_features(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); +struct LDKCoinSelection CoinSelection_clone(const struct LDKCoinSelection *NONNULL_PTR orig); /** - * Constructs a new BlindedPayInfo given each field + * Calls the free function if one is set */ -MUST_USE_RES struct LDKBlindedPayInfo BlindedPayInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKBlindedHopFeatures features_arg); +void CoinSelectionSource_free(struct LDKCoinSelectionSource this_ptr); /** - * Creates a copy of the BlindedPayInfo + * Calls the free function if one is set */ -struct LDKBlindedPayInfo BlindedPayInfo_clone(const struct LDKBlindedPayInfo *NONNULL_PTR orig); +void WalletSource_free(struct LDKWalletSource this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. + * Frees any resources used by the Wallet, if is_owned is set and inner is non-NULL. */ -uint64_t BlindedPayInfo_hash(const struct LDKBlindedPayInfo *NONNULL_PTR o); +void Wallet_free(struct LDKWallet this_obj); /** - * Checks if two BlindedPayInfos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Returns a new instance backed by the given [`WalletSource`] that serves as an implementation + * of [`CoinSelectionSource`]. */ -bool BlindedPayInfo_eq(const struct LDKBlindedPayInfo *NONNULL_PTR a, const struct LDKBlindedPayInfo *NONNULL_PTR b); +MUST_USE_RES struct LDKWallet Wallet_new(struct LDKWalletSource source, struct LDKLogger logger); /** - * Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read + * Constructs a new CoinSelectionSource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CoinSelectionSource must be freed before this_arg is */ -struct LDKCVec_u8Z BlindedPayInfo_write(const struct LDKBlindedPayInfo *NONNULL_PTR obj); +struct LDKCoinSelectionSource Wallet_as_CoinSelectionSource(const struct LDKWallet *NONNULL_PTR this_arg); /** - * Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write + * Frees any resources used by the BumpTransactionEventHandler, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ BlindedPayInfo_read(struct LDKu8slice ser); +void BumpTransactionEventHandler_free(struct LDKBumpTransactionEventHandler this_obj); /** - * Frees any resources used by the BlindedPaymentPath, if is_owned is set and inner is non-NULL. + * Returns a new instance capable of handling [`Event::BumpTransaction`] events. + * + * [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction */ -void BlindedPaymentPath_free(struct LDKBlindedPaymentPath this_obj); +MUST_USE_RES struct LDKBumpTransactionEventHandler BumpTransactionEventHandler_new(struct LDKBroadcasterInterface broadcaster, struct LDKCoinSelectionSource utxo_source, struct LDKSignerProvider signer_provider, struct LDKLogger logger); /** - * The [`BlindedPayInfo`] used to pay this blinded path. + * Handles all variants of [`BumpTransactionEvent`]. */ -struct LDKBlindedPayInfo BlindedPaymentPath_get_payinfo(const struct LDKBlindedPaymentPath *NONNULL_PTR this_ptr); +void BumpTransactionEventHandler_handle_event(const struct LDKBumpTransactionEventHandler *NONNULL_PTR this_arg, const struct LDKBumpTransactionEvent *NONNULL_PTR event); /** - * The [`BlindedPayInfo`] used to pay this blinded path. + * Checks if two InitFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void BlindedPaymentPath_set_payinfo(struct LDKBlindedPaymentPath *NONNULL_PTR this_ptr, struct LDKBlindedPayInfo val); +bool InitFeatures_eq(const struct LDKInitFeatures *NONNULL_PTR a, const struct LDKInitFeatures *NONNULL_PTR b); /** - * Creates a copy of the BlindedPaymentPath + * Checks if two NodeFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKBlindedPaymentPath BlindedPaymentPath_clone(const struct LDKBlindedPaymentPath *NONNULL_PTR orig); +bool NodeFeatures_eq(const struct LDKNodeFeatures *NONNULL_PTR a, const struct LDKNodeFeatures *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the BlindedPaymentPath. + * Checks if two ChannelFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint64_t BlindedPaymentPath_hash(const struct LDKBlindedPaymentPath *NONNULL_PTR o); +bool ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const struct LDKChannelFeatures *NONNULL_PTR b); /** - * Checks if two BlindedPaymentPaths contain equal inner contents. + * Checks if two Bolt11InvoiceFeaturess contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool BlindedPaymentPath_eq(const struct LDKBlindedPaymentPath *NONNULL_PTR a, const struct LDKBlindedPaymentPath *NONNULL_PTR b); +bool Bolt11InvoiceFeatures_eq(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR b); /** - * Create a one-hop blinded path for a payment. + * Checks if two OfferFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_BlindedPaymentPathNoneZ BlindedPaymentPath_one_hop(struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, uint16_t min_final_cltv_expiry_delta, struct LDKEntropySource entropy_source); +bool OfferFeatures_eq(const struct LDKOfferFeatures *NONNULL_PTR a, const struct LDKOfferFeatures *NONNULL_PTR b); /** - * Create a blinded path for a payment, to be forwarded along `intermediate_nodes`. - * - * Errors if: - * * a provided node id is invalid - * * [`BlindedPayInfo`] calculation results in an integer overflow - * * any unknown features are required in the provided [`ForwardTlvs`] + * Checks if two InvoiceRequestFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_BlindedPaymentPathNoneZ BlindedPaymentPath_new(struct LDKCVec_PaymentForwardNodeZ intermediate_nodes, struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, uint64_t htlc_maximum_msat, uint16_t min_final_cltv_expiry_delta, struct LDKEntropySource entropy_source); +bool InvoiceRequestFeatures_eq(const struct LDKInvoiceRequestFeatures *NONNULL_PTR a, const struct LDKInvoiceRequestFeatures *NONNULL_PTR b); /** - * Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., - * it is found in the network graph). - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two Bolt12InvoiceFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKNodeId BlindedPaymentPath_public_introduction_node_id(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); +bool Bolt12InvoiceFeatures_eq(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR b); /** - * The [`IntroductionNode`] of the blinded path. + * Checks if two BlindedHopFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKIntroductionNode BlindedPaymentPath_introduction_node(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); +bool BlindedHopFeatures_eq(const struct LDKBlindedHopFeatures *NONNULL_PTR a, const struct LDKBlindedHopFeatures *NONNULL_PTR b); /** - * Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the payment. - * - * [`encrypted_payload`]: BlindedHop::encrypted_payload + * Checks if two ChannelTypeFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKPublicKey BlindedPaymentPath_blinding_point(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); +bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b); /** - * The [`BlindedHop`]s within the blinded path. + * Creates a copy of the InitFeatures */ -MUST_USE_RES struct LDKCVec_BlindedHopZ BlindedPaymentPath_blinded_hops(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); +struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); /** - * Advance the blinded onion payment path by one hop, making the second hop into the new - * introduction node. - * - * Will only modify `self` when returning `Ok`. + * Creates a copy of the NodeFeatures */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedPaymentPath_advance_path_by_one(struct LDKBlindedPaymentPath *NONNULL_PTR this_arg, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup); +struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); /** - * Frees any resources used by the PaymentForwardNode, if is_owned is set and inner is non-NULL. + * Creates a copy of the ChannelFeatures */ -void PaymentForwardNode_free(struct LDKPaymentForwardNode this_obj); +struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); /** - * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also - * used for [`BlindedPayInfo`] construction. + * Creates a copy of the Bolt11InvoiceFeatures */ -struct LDKForwardTlvs PaymentForwardNode_get_tlvs(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); +struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_clone(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR orig); /** - * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also - * used for [`BlindedPayInfo`] construction. + * Creates a copy of the OfferFeatures */ -void PaymentForwardNode_set_tlvs(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, struct LDKForwardTlvs val); +struct LDKOfferFeatures OfferFeatures_clone(const struct LDKOfferFeatures *NONNULL_PTR orig); /** - * This node's pubkey. + * Creates a copy of the InvoiceRequestFeatures */ -struct LDKPublicKey PaymentForwardNode_get_node_id(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); +struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_clone(const struct LDKInvoiceRequestFeatures *NONNULL_PTR orig); /** - * This node's pubkey. + * Creates a copy of the Bolt12InvoiceFeatures */ -void PaymentForwardNode_set_node_id(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_clone(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR orig); /** - * The maximum value, in msat, that may be accepted by this node. + * Creates a copy of the BlindedHopFeatures */ -uint64_t PaymentForwardNode_get_htlc_maximum_msat(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); +struct LDKBlindedHopFeatures BlindedHopFeatures_clone(const struct LDKBlindedHopFeatures *NONNULL_PTR orig); /** - * The maximum value, in msat, that may be accepted by this node. + * Creates a copy of the ChannelTypeFeatures */ -void PaymentForwardNode_set_htlc_maximum_msat(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, uint64_t val); +struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig); /** - * Constructs a new PaymentForwardNode given each field + * Generates a non-cryptographic 64-bit hash of the InitFeatures. */ -MUST_USE_RES struct LDKPaymentForwardNode PaymentForwardNode_new(struct LDKForwardTlvs tlvs_arg, struct LDKPublicKey node_id_arg, uint64_t htlc_maximum_msat_arg); +uint64_t InitFeatures_hash(const struct LDKInitFeatures *NONNULL_PTR o); /** - * Creates a copy of the PaymentForwardNode + * Generates a non-cryptographic 64-bit hash of the NodeFeatures. */ -struct LDKPaymentForwardNode PaymentForwardNode_clone(const struct LDKPaymentForwardNode *NONNULL_PTR orig); +uint64_t NodeFeatures_hash(const struct LDKNodeFeatures *NONNULL_PTR o); /** - * Frees any resources used by the ForwardTlvs, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the ChannelFeatures. */ -void ForwardTlvs_free(struct LDKForwardTlvs this_obj); +uint64_t ChannelFeatures_hash(const struct LDKChannelFeatures *NONNULL_PTR o); /** - * The short channel id this payment should be forwarded out over. + * Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures. */ -uint64_t ForwardTlvs_get_short_channel_id(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +uint64_t Bolt11InvoiceFeatures_hash(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR o); /** - * The short channel id this payment should be forwarded out over. + * Generates a non-cryptographic 64-bit hash of the OfferFeatures. */ -void ForwardTlvs_set_short_channel_id(struct LDKForwardTlvs *NONNULL_PTR this_ptr, uint64_t val); +uint64_t OfferFeatures_hash(const struct LDKOfferFeatures *NONNULL_PTR o); /** - * Payment parameters for relaying over [`Self::short_channel_id`]. + * Generates a non-cryptographic 64-bit hash of the InvoiceRequestFeatures. */ -struct LDKPaymentRelay ForwardTlvs_get_payment_relay(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +uint64_t InvoiceRequestFeatures_hash(const struct LDKInvoiceRequestFeatures *NONNULL_PTR o); /** - * Payment parameters for relaying over [`Self::short_channel_id`]. + * Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures. */ -void ForwardTlvs_set_payment_relay(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentRelay val); +uint64_t Bolt12InvoiceFeatures_hash(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR o); /** - * Payment constraints for relaying over [`Self::short_channel_id`]. + * Generates a non-cryptographic 64-bit hash of the BlindedHopFeatures. */ -struct LDKPaymentConstraints ForwardTlvs_get_payment_constraints(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +uint64_t BlindedHopFeatures_hash(const struct LDKBlindedHopFeatures *NONNULL_PTR o); /** - * Payment constraints for relaying over [`Self::short_channel_id`]. + * Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures. */ -void ForwardTlvs_set_payment_constraints(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); +uint64_t ChannelTypeFeatures_hash(const struct LDKChannelTypeFeatures *NONNULL_PTR o); /** - * Supported and required features when relaying a payment onion containing this object's - * corresponding [`BlindedHop::encrypted_payload`]. - * - * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload + * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKBlindedHopFeatures ForwardTlvs_get_features(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +void InitFeatures_free(struct LDKInitFeatures this_obj); /** - * Supported and required features when relaying a payment onion containing this object's - * corresponding [`BlindedHop::encrypted_payload`]. - * - * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload + * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. */ -void ForwardTlvs_set_features(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); +void NodeFeatures_free(struct LDKNodeFeatures this_obj); /** - * Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the - * [`BlindedPaymentPath::blinding_point`] of the appended blinded path. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey ForwardTlvs_get_next_blinding_override(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +void ChannelFeatures_free(struct LDKChannelFeatures this_obj); /** - * Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the - * [`BlindedPaymentPath::blinding_point`] of the appended blinded path. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. */ -void ForwardTlvs_set_next_blinding_override(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void Bolt11InvoiceFeatures_free(struct LDKBolt11InvoiceFeatures this_obj); /** - * Constructs a new ForwardTlvs given each field - * - * Note that next_blinding_override_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKForwardTlvs ForwardTlvs_new(uint64_t short_channel_id_arg, struct LDKPaymentRelay payment_relay_arg, struct LDKPaymentConstraints payment_constraints_arg, struct LDKBlindedHopFeatures features_arg, struct LDKPublicKey next_blinding_override_arg); +void OfferFeatures_free(struct LDKOfferFeatures this_obj); /** - * Creates a copy of the ForwardTlvs + * Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKForwardTlvs ForwardTlvs_clone(const struct LDKForwardTlvs *NONNULL_PTR orig); +void InvoiceRequestFeatures_free(struct LDKInvoiceRequestFeatures this_obj); /** - * Frees any resources used by the ReceiveTlvs, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. */ -void ReceiveTlvs_free(struct LDKReceiveTlvs this_obj); +void Bolt12InvoiceFeatures_free(struct LDKBolt12InvoiceFeatures this_obj); /** - * Creates a copy of the ReceiveTlvs + * Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKReceiveTlvs ReceiveTlvs_clone(const struct LDKReceiveTlvs *NONNULL_PTR orig); +void BlindedHopFeatures_free(struct LDKBlindedHopFeatures this_obj); /** - * Returns the underlying TLVs. + * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKUnauthenticatedReceiveTlvs ReceiveTlvs_tlvs(const struct LDKReceiveTlvs *NONNULL_PTR this_arg); +void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); /** - * Frees any resources used by the UnauthenticatedReceiveTlvs, if is_owned is set and inner is non-NULL. + * Getting a route for a keysend payment to a private node requires providing the payee's + * features (since they were not announced in a node announcement). However, keysend payments + * don't have an invoice to pull the payee's features from, so this method is provided for use + * when a [`Bolt11InvoiceFeatures`] is required in a route. + * + * MPP keysend is not widely supported yet, so we parameterize support to allow the user to + * choose whether their router should find multi-part routes. */ -void UnauthenticatedReceiveTlvs_free(struct LDKUnauthenticatedReceiveTlvs this_obj); +MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_for_keysend(bool allow_mpp); /** - * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. + * Constructs a ChannelTypeFeatures with only static_remotekey set */ -const uint8_t (*UnauthenticatedReceiveTlvs_get_payment_secret(const struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_only_static_remote_key(void); /** - * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. + * Constructs a ChannelTypeFeatures with anchors support */ -void UnauthenticatedReceiveTlvs_set_payment_secret(struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_anchors_zero_htlc_fee_and_dependencies(void); /** - * Constraints for the receiver of this payment. + * Create a blank Features with no features set */ -struct LDKPaymentConstraints UnauthenticatedReceiveTlvs_get_payment_constraints(const struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); /** - * Constraints for the receiver of this payment. + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -void UnauthenticatedReceiveTlvs_set_payment_constraints(struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); +MUST_USE_RES struct LDKu8slice InitFeatures_le_flags(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Context for the receiver of this payment. + * Returns true if this `Features` has any optional flags set */ -struct LDKPaymentContext UnauthenticatedReceiveTlvs_get_payment_context(const struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr); +MUST_USE_RES bool InitFeatures_supports_any_optional_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Context for the receiver of this payment. + * Returns true if this `Features` object contains required features unknown by `other`. */ -void UnauthenticatedReceiveTlvs_set_payment_context(struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR this_ptr, struct LDKPaymentContext val); +MUST_USE_RES bool InitFeatures_requires_unknown_bits_from(const struct LDKInitFeatures *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR other); /** - * Constructs a new UnauthenticatedReceiveTlvs given each field + * Returns the set of required features unknown by `other`, as their bit position. */ -MUST_USE_RES struct LDKUnauthenticatedReceiveTlvs UnauthenticatedReceiveTlvs_new(struct LDKThirtyTwoBytes payment_secret_arg, struct LDKPaymentConstraints payment_constraints_arg, struct LDKPaymentContext payment_context_arg); +MUST_USE_RES struct LDKCVec_u64Z InitFeatures_required_unknown_bits_from(const struct LDKInitFeatures *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR other); /** - * Creates a copy of the UnauthenticatedReceiveTlvs + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKUnauthenticatedReceiveTlvs UnauthenticatedReceiveTlvs_clone(const struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates an authenticated [`ReceiveTlvs`], which includes an HMAC and the provide [`Nonce`] - * that can be use later to verify it authenticity. + * Returns true if this `Features` supports any bits which we do not know of */ -MUST_USE_RES struct LDKReceiveTlvs UnauthenticatedReceiveTlvs_authenticate(struct LDKUnauthenticatedReceiveTlvs this_arg, struct LDKNonce nonce, const struct LDKExpandedKey *NONNULL_PTR expanded_key); +MUST_USE_RES bool InitFeatures_supports_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PaymentRelay, if is_owned is set and inner is non-NULL. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void PaymentRelay_free(struct LDKPaymentRelay this_obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -uint16_t PaymentRelay_get_cltv_expiry_delta(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void PaymentRelay_set_cltv_expiry_delta(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over - * this [`BlindedHop`], (i.e., 10,000 is 1%). + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -uint32_t PaymentRelay_get_fee_proportional_millionths(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over - * this [`BlindedHop`], (i.e., 10,000 is 1%). + * Create a blank Features with no features set */ -void PaymentRelay_set_fee_proportional_millionths(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); /** - * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -uint32_t PaymentRelay_get_fee_base_msat(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKu8slice NodeFeatures_le_flags(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. + * Returns true if this `Features` has any optional flags set */ -void PaymentRelay_set_fee_base_msat(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES bool NodeFeatures_supports_any_optional_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new PaymentRelay given each field + * Returns true if this `Features` object contains required features unknown by `other`. */ -MUST_USE_RES struct LDKPaymentRelay PaymentRelay_new(uint16_t cltv_expiry_delta_arg, uint32_t fee_proportional_millionths_arg, uint32_t fee_base_msat_arg); +MUST_USE_RES bool NodeFeatures_requires_unknown_bits_from(const struct LDKNodeFeatures *NONNULL_PTR this_arg, const struct LDKNodeFeatures *NONNULL_PTR other); /** - * Creates a copy of the PaymentRelay + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKPaymentRelay PaymentRelay_clone(const struct LDKPaymentRelay *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_u64Z NodeFeatures_required_unknown_bits_from(const struct LDKNodeFeatures *NONNULL_PTR this_arg, const struct LDKNodeFeatures *NONNULL_PTR other); /** - * Frees any resources used by the PaymentConstraints, if is_owned is set and inner is non-NULL. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -void PaymentConstraints_free(struct LDKPaymentConstraints this_obj); +MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. + * Returns true if this `Features` supports any bits which we do not know of */ -uint32_t PaymentConstraints_get_max_cltv_expiry(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void PaymentConstraints_set_max_cltv_expiry(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The minimum value, in msat, that may be accepted by the node corresponding to this - * [`BlindedHop`]. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -uint64_t PaymentConstraints_get_htlc_minimum_msat(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The minimum value, in msat, that may be accepted by the node corresponding to this - * [`BlindedHop`]. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void PaymentConstraints_set_htlc_minimum_msat(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Constructs a new PaymentConstraints given each field + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -MUST_USE_RES struct LDKPaymentConstraints PaymentConstraints_new(uint32_t max_cltv_expiry_arg, uint64_t htlc_minimum_msat_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of the PaymentConstraints + * Create a blank Features with no features set */ -struct LDKPaymentConstraints PaymentConstraints_clone(const struct LDKPaymentConstraints *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); /** - * Frees any resources used by the PaymentContext + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -void PaymentContext_free(struct LDKPaymentContext this_ptr); +MUST_USE_RES struct LDKu8slice ChannelFeatures_le_flags(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentContext + * Returns true if this `Features` has any optional flags set */ -struct LDKPaymentContext PaymentContext_clone(const struct LDKPaymentContext *NONNULL_PTR orig); +MUST_USE_RES bool ChannelFeatures_supports_any_optional_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Bolt12Offer-variant PaymentContext + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKPaymentContext PaymentContext_bolt12_offer(struct LDKBolt12OfferContext a); +MUST_USE_RES bool ChannelFeatures_requires_unknown_bits_from(const struct LDKChannelFeatures *NONNULL_PTR this_arg, const struct LDKChannelFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new Bolt12Refund-variant PaymentContext + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKPaymentContext PaymentContext_bolt12_refund(struct LDKBolt12RefundContext a); +MUST_USE_RES struct LDKCVec_u64Z ChannelFeatures_required_unknown_bits_from(const struct LDKChannelFeatures *NONNULL_PTR this_arg, const struct LDKChannelFeatures *NONNULL_PTR other); /** - * Checks if two PaymentContexts contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -bool PaymentContext_eq(const struct LDKPaymentContext *NONNULL_PTR a, const struct LDKPaymentContext *NONNULL_PTR b); +MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Bolt12OfferContext, if is_owned is set and inner is non-NULL. + * Returns true if this `Features` supports any bits which we do not know of */ -void Bolt12OfferContext_free(struct LDKBolt12OfferContext this_obj); +MUST_USE_RES bool ChannelFeatures_supports_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * The identifier of the [`Offer`]. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. * - * [`Offer`]: crate::offers::offer::Offer + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKOfferId Bolt12OfferContext_get_offer_id(const struct LDKBolt12OfferContext *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The identifier of the [`Offer`]. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. * - * [`Offer`]: crate::offers::offer::Offer + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void Bolt12OfferContext_set_offer_id(struct LDKBolt12OfferContext *NONNULL_PTR this_ptr, struct LDKOfferId val); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKInvoiceRequestFields Bolt12OfferContext_get_invoice_request(const struct LDKBolt12OfferContext *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void Bolt12OfferContext_set_invoice_request(struct LDKBolt12OfferContext *NONNULL_PTR this_ptr, struct LDKInvoiceRequestFields val); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Constructs a new Bolt12OfferContext given each field + * Create a blank Features with no features set */ -MUST_USE_RES struct LDKBolt12OfferContext Bolt12OfferContext_new(struct LDKOfferId offer_id_arg, struct LDKInvoiceRequestFields invoice_request_arg); +MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_empty(void); /** - * Creates a copy of the Bolt12OfferContext + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -struct LDKBolt12OfferContext Bolt12OfferContext_clone(const struct LDKBolt12OfferContext *NONNULL_PTR orig); +MUST_USE_RES struct LDKu8slice Bolt11InvoiceFeatures_le_flags(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Checks if two Bolt12OfferContexts contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Returns true if this `Features` has any optional flags set */ -bool Bolt12OfferContext_eq(const struct LDKBolt12OfferContext *NONNULL_PTR a, const struct LDKBolt12OfferContext *NONNULL_PTR b); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_any_optional_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Bolt12RefundContext, if is_owned is set and inner is non-NULL. + * Returns true if this `Features` object contains required features unknown by `other`. */ -void Bolt12RefundContext_free(struct LDKBolt12RefundContext this_obj); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR other); /** - * Constructs a new Bolt12RefundContext given each field + * Returns the set of required features unknown by `other`, as their bit position. */ -MUST_USE_RES struct LDKBolt12RefundContext Bolt12RefundContext_new(void); +MUST_USE_RES struct LDKCVec_u64Z Bolt11InvoiceFeatures_required_unknown_bits_from(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR other); /** - * Creates a copy of the Bolt12RefundContext + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKBolt12RefundContext Bolt12RefundContext_clone(const struct LDKBolt12RefundContext *NONNULL_PTR orig); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Checks if two Bolt12RefundContexts contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Returns true if this `Features` supports any bits which we do not know of */ -bool Bolt12RefundContext_eq(const struct LDKBolt12RefundContext *NONNULL_PTR a, const struct LDKBolt12RefundContext *NONNULL_PTR b); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_unknown_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Serialize the ForwardTlvs object into a byte array which can be read by ForwardTlvs_read + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKCVec_u8Z ForwardTlvs_write(const struct LDKForwardTlvs *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKCVec_u8Z ReceiveTlvs_write(const struct LDKReceiveTlvs *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Serialize the UnauthenticatedReceiveTlvs object into a byte array which can be read by UnauthenticatedReceiveTlvs_read + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKCVec_u8Z UnauthenticatedReceiveTlvs_write(const struct LDKUnauthenticatedReceiveTlvs *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Serialize the PaymentRelay object into a byte array which can be read by PaymentRelay_read + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKCVec_u8Z PaymentRelay_write(const struct LDKPaymentRelay *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Read a PaymentRelay from a byte array, created by PaymentRelay_write + * Create a blank Features with no features set */ -struct LDKCResult_PaymentRelayDecodeErrorZ PaymentRelay_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKOfferFeatures OfferFeatures_empty(void); /** - * Serialize the PaymentConstraints object into a byte array which can be read by PaymentConstraints_read + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -struct LDKCVec_u8Z PaymentConstraints_write(const struct LDKPaymentConstraints *NONNULL_PTR obj); +MUST_USE_RES struct LDKu8slice OfferFeatures_le_flags(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentConstraints from a byte array, created by PaymentConstraints_write + * Returns true if this `Features` has any optional flags set */ -struct LDKCResult_PaymentConstraintsDecodeErrorZ PaymentConstraints_read(struct LDKu8slice ser); +MUST_USE_RES bool OfferFeatures_supports_any_optional_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentContext object into a byte array which can be read by PaymentContext_read + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKCVec_u8Z PaymentContext_write(const struct LDKPaymentContext *NONNULL_PTR obj); +MUST_USE_RES bool OfferFeatures_requires_unknown_bits_from(const struct LDKOfferFeatures *NONNULL_PTR this_arg, const struct LDKOfferFeatures *NONNULL_PTR other); /** - * Read a PaymentContext from a byte array, created by PaymentContext_write + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKCResult_PaymentContextDecodeErrorZ PaymentContext_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCVec_u64Z OfferFeatures_required_unknown_bits_from(const struct LDKOfferFeatures *NONNULL_PTR this_arg, const struct LDKOfferFeatures *NONNULL_PTR other); /** - * Serialize the Bolt12OfferContext object into a byte array which can be read by Bolt12OfferContext_read + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKCVec_u8Z Bolt12OfferContext_write(const struct LDKBolt12OfferContext *NONNULL_PTR obj); +MUST_USE_RES bool OfferFeatures_requires_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Read a Bolt12OfferContext from a byte array, created by Bolt12OfferContext_write + * Returns true if this `Features` supports any bits which we do not know of */ -struct LDKCResult_Bolt12OfferContextDecodeErrorZ Bolt12OfferContext_read(struct LDKu8slice ser); +MUST_USE_RES bool OfferFeatures_supports_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Serialize the Bolt12RefundContext object into a byte array which can be read by Bolt12RefundContext_read + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKCVec_u8Z Bolt12RefundContext_write(const struct LDKBolt12RefundContext *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Read a Bolt12RefundContext from a byte array, created by Bolt12RefundContext_write + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKCResult_Bolt12RefundContextDecodeErrorZ Bolt12RefundContext_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the BlindedMessagePath, if is_owned is set and inner is non-NULL. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void BlindedMessagePath_free(struct LDKBlindedMessagePath this_obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of the BlindedMessagePath + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKBlindedMessagePath BlindedMessagePath_clone(const struct LDKBlindedMessagePath *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Generates a non-cryptographic 64-bit hash of the BlindedMessagePath. + * Create a blank Features with no features set */ -uint64_t BlindedMessagePath_hash(const struct LDKBlindedMessagePath *NONNULL_PTR o); +MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_empty(void); /** - * Checks if two BlindedMessagePaths contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -bool BlindedMessagePath_eq(const struct LDKBlindedMessagePath *NONNULL_PTR a, const struct LDKBlindedMessagePath *NONNULL_PTR b); +MUST_USE_RES struct LDKu8slice InvoiceRequestFeatures_le_flags(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * Serialize the BlindedMessagePath object into a byte array which can be read by BlindedMessagePath_read + * Returns true if this `Features` has any optional flags set */ -struct LDKCVec_u8Z BlindedMessagePath_write(const struct LDKBlindedMessagePath *NONNULL_PTR obj); +MUST_USE_RES bool InvoiceRequestFeatures_supports_any_optional_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * Read a BlindedMessagePath from a byte array, created by BlindedMessagePath_write + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKCResult_BlindedMessagePathDecodeErrorZ BlindedMessagePath_read(struct LDKu8slice ser); +MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits_from(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, const struct LDKInvoiceRequestFeatures *NONNULL_PTR other); /** - * Create a one-hop blinded path for a message. + * Returns the set of required features unknown by `other`, as their bit position. */ -MUST_USE_RES struct LDKCResult_BlindedMessagePathNoneZ BlindedMessagePath_one_hop(struct LDKPublicKey recipient_node_id, struct LDKMessageContext context, struct LDKEntropySource entropy_source); +MUST_USE_RES struct LDKCVec_u64Z InvoiceRequestFeatures_required_unknown_bits_from(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, const struct LDKInvoiceRequestFeatures *NONNULL_PTR other); /** - * Create a path for an onion message, to be forwarded along `node_pks`. The last node - * pubkey in `node_pks` will be the destination node. - * - * Errors if no hops are provided or if `node_pk`(s) are invalid. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -MUST_USE_RES struct LDKCResult_BlindedMessagePathNoneZ BlindedMessagePath_new(struct LDKCVec_MessageForwardNodeZ intermediate_nodes, struct LDKPublicKey recipient_node_id, struct LDKMessageContext context, struct LDKEntropySource entropy_source); +MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * Attempts to a use a compact representation for the [`IntroductionNode`] by using a directed - * short channel id from a channel in `network_graph` leading to the introduction node. + * Returns true if this `Features` supports any bits which we do not know of + */ +MUST_USE_RES bool InvoiceRequestFeatures_supports_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); + +/** + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. * - * While this may result in a smaller encoding, there is a trade off in that the path may - * become invalid if the channel is closed or hasn't been propagated via gossip. Therefore, - * calling this may not be suitable for long-lived blinded paths. + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void BlindedMessagePath_use_compact_introduction_node(struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., - * it is found in the network graph). + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -MUST_USE_RES struct LDKNodeId BlindedMessagePath_public_introduction_node_id(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The [`IntroductionNode`] of the blinded path. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -MUST_USE_RES struct LDKIntroductionNode BlindedMessagePath_introduction_node(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the message. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * [`encrypted_payload`]: BlindedHop::encrypted_payload + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -MUST_USE_RES struct LDKPublicKey BlindedMessagePath_blinding_point(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The [`BlindedHop`]s within the blinded path. + * Create a blank Features with no features set */ -MUST_USE_RES struct LDKCVec_BlindedHopZ BlindedMessagePath_blinded_hops(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_empty(void); /** - * Advance the blinded onion message path by one hop, making the second hop into the new - * introduction node. - * - * Will only modify `self` when returning `Ok`. + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedMessagePath_advance_path_by_one(struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup); +MUST_USE_RES struct LDKu8slice Bolt12InvoiceFeatures_le_flags(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the NextMessageHop + * Returns true if this `Features` has any optional flags set */ -void NextMessageHop_free(struct LDKNextMessageHop this_ptr); +MUST_USE_RES bool Bolt12InvoiceFeatures_supports_any_optional_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the NextMessageHop + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKNextMessageHop NextMessageHop_clone(const struct LDKNextMessageHop *NONNULL_PTR orig); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new NodeId-variant NextMessageHop + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKNextMessageHop NextMessageHop_node_id(struct LDKPublicKey a); +MUST_USE_RES struct LDKCVec_u64Z Bolt12InvoiceFeatures_required_unknown_bits_from(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new ShortChannelId-variant NextMessageHop + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKNextMessageHop NextMessageHop_short_channel_id(uint64_t a); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the NextMessageHop. + * Returns true if this `Features` supports any bits which we do not know of */ -uint64_t NextMessageHop_hash(const struct LDKNextMessageHop *NONNULL_PTR o); +MUST_USE_RES bool Bolt12InvoiceFeatures_supports_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Checks if two NextMessageHops contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -bool NextMessageHop_eq(const struct LDKNextMessageHop *NONNULL_PTR a, const struct LDKNextMessageHop *NONNULL_PTR b); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the MessageForwardNode, if is_owned is set and inner is non-NULL. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void MessageForwardNode_free(struct LDKMessageForwardNode this_obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * This node's pubkey. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKPublicKey MessageForwardNode_get_node_id(const struct LDKMessageForwardNode *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * This node's pubkey. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void MessageForwardNode_set_node_id(struct LDKMessageForwardNode *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s - * `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a - * more compact representation. + * Create a blank Features with no features set */ -struct LDKCOption_u64Z MessageForwardNode_get_short_channel_id(const struct LDKMessageForwardNode *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKBlindedHopFeatures BlindedHopFeatures_empty(void); /** - * The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s - * `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a - * more compact representation. + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -void MessageForwardNode_set_short_channel_id(struct LDKMessageForwardNode *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKu8slice BlindedHopFeatures_le_flags(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * Constructs a new MessageForwardNode given each field + * Returns true if this `Features` has any optional flags set */ -MUST_USE_RES struct LDKMessageForwardNode MessageForwardNode_new(struct LDKPublicKey node_id_arg, struct LDKCOption_u64Z short_channel_id_arg); +MUST_USE_RES bool BlindedHopFeatures_supports_any_optional_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the MessageForwardNode + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKMessageForwardNode MessageForwardNode_clone(const struct LDKMessageForwardNode *NONNULL_PTR orig); +MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits_from(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, const struct LDKBlindedHopFeatures *NONNULL_PTR other); /** - * Generates a non-cryptographic 64-bit hash of the MessageForwardNode. + * Returns the set of required features unknown by `other`, as their bit position. */ -uint64_t MessageForwardNode_hash(const struct LDKMessageForwardNode *NONNULL_PTR o); +MUST_USE_RES struct LDKCVec_u64Z BlindedHopFeatures_required_unknown_bits_from(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, const struct LDKBlindedHopFeatures *NONNULL_PTR other); /** - * Checks if two MessageForwardNodes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -bool MessageForwardNode_eq(const struct LDKMessageForwardNode *NONNULL_PTR a, const struct LDKMessageForwardNode *NONNULL_PTR b); +MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the MessageContext + * Returns true if this `Features` supports any bits which we do not know of */ -void MessageContext_free(struct LDKMessageContext this_ptr); +MUST_USE_RES bool BlindedHopFeatures_supports_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the MessageContext + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKMessageContext MessageContext_clone(const struct LDKMessageContext *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new Offers-variant MessageContext + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKMessageContext MessageContext_offers(struct LDKOffersContext a); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new AsyncPayments-variant MessageContext + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKMessageContext MessageContext_async_payments(struct LDKAsyncPaymentsContext a); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new DNSResolver-variant MessageContext + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKMessageContext MessageContext_dnsresolver(struct LDKDNSResolverContext a); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new Custom-variant MessageContext + * Create a blank Features with no features set */ -struct LDKMessageContext MessageContext_custom(struct LDKCVec_u8Z a); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); /** - * Frees any resources used by the OffersContext + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -void OffersContext_free(struct LDKOffersContext this_ptr); +MUST_USE_RES struct LDKu8slice ChannelTypeFeatures_le_flags(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the OffersContext + * Returns true if this `Features` has any optional flags set */ -struct LDKOffersContext OffersContext_clone(const struct LDKOffersContext *NONNULL_PTR orig); +MUST_USE_RES bool ChannelTypeFeatures_supports_any_optional_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvoiceRequest-variant OffersContext + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKOffersContext OffersContext_invoice_request(struct LDKNonce nonce); +MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits_from(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, const struct LDKChannelTypeFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new OutboundPayment-variant OffersContext + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKOffersContext OffersContext_outbound_payment(struct LDKThirtyTwoBytes payment_id, struct LDKNonce nonce, struct LDKThirtyTwoBytes hmac); +MUST_USE_RES struct LDKCVec_u64Z ChannelTypeFeatures_required_unknown_bits_from(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, const struct LDKChannelTypeFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new InboundPayment-variant OffersContext + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKOffersContext OffersContext_inbound_payment(struct LDKThirtyTwoBytes payment_hash, struct LDKNonce nonce, struct LDKThirtyTwoBytes hmac); +MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Checks if two OffersContexts contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Returns true if this `Features` supports any bits which we do not know of */ -bool OffersContext_eq(const struct LDKOffersContext *NONNULL_PTR a, const struct LDKOffersContext *NONNULL_PTR b); +MUST_USE_RES bool ChannelTypeFeatures_supports_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the AsyncPaymentsContext + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void AsyncPaymentsContext_free(struct LDKAsyncPaymentsContext this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of the AsyncPaymentsContext + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKAsyncPaymentsContext AsyncPaymentsContext_clone(const struct LDKAsyncPaymentsContext *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new OutboundPayment-variant AsyncPaymentsContext + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKAsyncPaymentsContext AsyncPaymentsContext_outbound_payment(struct LDKThirtyTwoBytes payment_id, struct LDKNonce nonce, struct LDKThirtyTwoBytes hmac); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Serialize the MessageContext object into a byte array which can be read by MessageContext_read + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKCVec_u8Z MessageContext_write(const struct LDKMessageContext *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Read a MessageContext from a byte array, created by MessageContext_write + * Unsets the `upfront_shutdown_script` feature */ -struct LDKCResult_MessageContextDecodeErrorZ MessageContext_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_upfront_shutdown_script(struct LDKInitFeatures this_arg); /** - * Serialize the OffersContext object into a byte array which can be read by OffersContext_read + * Unsets the `upfront_shutdown_script` feature */ -struct LDKCVec_u8Z OffersContext_write(const struct LDKOffersContext *NONNULL_PTR obj); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_upfront_shutdown_script(struct LDKNodeFeatures this_arg); /** - * Read a OffersContext from a byte array, created by OffersContext_write + * Unsets the `shutdown_anysegwit` feature */ -struct LDKCResult_OffersContextDecodeErrorZ OffersContext_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_shutdown_anysegwit(struct LDKInitFeatures this_arg); /** - * Serialize the AsyncPaymentsContext object into a byte array which can be read by AsyncPaymentsContext_read + * Unsets the `shutdown_anysegwit` feature */ -struct LDKCVec_u8Z AsyncPaymentsContext_write(const struct LDKAsyncPaymentsContext *NONNULL_PTR obj); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_shutdown_anysegwit(struct LDKNodeFeatures this_arg); /** - * Read a AsyncPaymentsContext from a byte array, created by AsyncPaymentsContext_write + * Unsets the `wumbo` feature */ -struct LDKCResult_AsyncPaymentsContextDecodeErrorZ AsyncPaymentsContext_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_wumbo(struct LDKInitFeatures this_arg); /** - * Frees any resources used by the DNSResolverContext, if is_owned is set and inner is non-NULL. + * Unsets the `wumbo` feature */ -void DNSResolverContext_free(struct LDKDNSResolverContext this_obj); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_wumbo(struct LDKNodeFeatures this_arg); /** - * A nonce which uniquely describes a DNS resolution. - * - * When we receive a DNSSEC proof message, we should check that it was sent over the blinded - * path we included in the request by comparing a stored nonce with this one. + * Unsets the `scid_privacy` feature */ -const uint8_t (*DNSResolverContext_get_nonce(const struct LDKDNSResolverContext *NONNULL_PTR this_ptr))[16]; +void InitFeatures_clear_scid_privacy(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * A nonce which uniquely describes a DNS resolution. - * - * When we receive a DNSSEC proof message, we should check that it was sent over the blinded - * path we included in the request by comparing a stored nonce with this one. + * Unsets the `scid_privacy` feature */ -void DNSResolverContext_set_nonce(struct LDKDNSResolverContext *NONNULL_PTR this_ptr, struct LDKSixteenBytes val); +void NodeFeatures_clear_scid_privacy(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new DNSResolverContext given each field + * Unsets the `scid_privacy` feature */ -MUST_USE_RES struct LDKDNSResolverContext DNSResolverContext_new(struct LDKSixteenBytes nonce_arg); +void ChannelTypeFeatures_clear_scid_privacy(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the DNSResolverContext + * Unsets the `anchors_zero_fee_htlc_tx` feature */ -struct LDKDNSResolverContext DNSResolverContext_clone(const struct LDKDNSResolverContext *NONNULL_PTR orig); +void InitFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the DNSResolverContext. + * Unsets the `anchors_zero_fee_htlc_tx` feature */ -uint64_t DNSResolverContext_hash(const struct LDKDNSResolverContext *NONNULL_PTR o); +void NodeFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two DNSResolverContexts contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Unsets the `anchors_zero_fee_htlc_tx` feature */ -bool DNSResolverContext_eq(const struct LDKDNSResolverContext *NONNULL_PTR a, const struct LDKDNSResolverContext *NONNULL_PTR b); +void ChannelTypeFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Serialize the DNSResolverContext object into a byte array which can be read by DNSResolverContext_read + * Unsets the `route_blinding` feature */ -struct LDKCVec_u8Z DNSResolverContext_write(const struct LDKDNSResolverContext *NONNULL_PTR obj); +void InitFeatures_clear_route_blinding(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a DNSResolverContext from a byte array, created by DNSResolverContext_write + * Unsets the `route_blinding` feature */ -struct LDKCResult_DNSResolverContextDecodeErrorZ DNSResolverContext_read(struct LDKu8slice ser); +void NodeFeatures_clear_route_blinding(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the FundingInfo + * Set this feature as optional. */ -void FundingInfo_free(struct LDKFundingInfo this_ptr); +void InitFeatures_set_data_loss_protect_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the FundingInfo + * Set this feature as required. */ -struct LDKFundingInfo FundingInfo_clone(const struct LDKFundingInfo *NONNULL_PTR orig); +void InitFeatures_set_data_loss_protect_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Tx-variant FundingInfo + * Checks if this feature is supported. */ -struct LDKFundingInfo FundingInfo_tx(struct LDKTransaction transaction); +MUST_USE_RES bool InitFeatures_supports_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OutPoint-variant FundingInfo + * Set this feature as optional. */ -struct LDKFundingInfo FundingInfo_out_point(struct LDKOutPoint outpoint); +void NodeFeatures_set_data_loss_protect_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two FundingInfos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as required. */ -bool FundingInfo_eq(const struct LDKFundingInfo *NONNULL_PTR a, const struct LDKFundingInfo *NONNULL_PTR b); +void NodeFeatures_set_data_loss_protect_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the FundingInfo object into a byte array which can be read by FundingInfo_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z FundingInfo_write(const struct LDKFundingInfo *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_supports_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a FundingInfo from a byte array, created by FundingInfo_write + * Checks if this feature is required. */ -struct LDKCResult_FundingInfoDecodeErrorZ FundingInfo_read(struct LDKu8slice ser); +MUST_USE_RES bool InitFeatures_requires_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PaymentPurpose + * Checks if this feature is required. */ -void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); +MUST_USE_RES bool NodeFeatures_requires_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentPurpose + * Set this feature as optional. */ -struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig); +void InitFeatures_set_initial_routing_sync_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Bolt11InvoicePayment-variant PaymentPurpose + * Set this feature as required. */ -struct LDKPaymentPurpose PaymentPurpose_bolt11_invoice_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret); +void InitFeatures_set_initial_routing_sync_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Bolt12OfferPayment-variant PaymentPurpose + * Checks if this feature is supported. */ -struct LDKPaymentPurpose PaymentPurpose_bolt12_offer_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret, struct LDKBolt12OfferContext payment_context); +MUST_USE_RES bool InitFeatures_initial_routing_sync(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Bolt12RefundPayment-variant PaymentPurpose + * Set this feature as optional. */ -struct LDKPaymentPurpose PaymentPurpose_bolt12_refund_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret, struct LDKBolt12RefundContext payment_context); +void InitFeatures_set_upfront_shutdown_script_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose + * Set this feature as required. */ -struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a); +void InitFeatures_set_upfront_shutdown_script_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two PaymentPurposes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if this feature is supported. */ -bool PaymentPurpose_eq(const struct LDKPaymentPurpose *NONNULL_PTR a, const struct LDKPaymentPurpose *NONNULL_PTR b); +MUST_USE_RES bool InitFeatures_supports_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Returns the preimage for this payment, if it is known. + * Set this feature as optional. */ -MUST_USE_RES struct LDKCOption_ThirtyTwoBytesZ PaymentPurpose_preimage(const struct LDKPaymentPurpose *NONNULL_PTR this_arg); +void NodeFeatures_set_upfront_shutdown_script_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read + * Set this feature as required. */ -struct LDKCVec_u8Z PaymentPurpose_write(const struct LDKPaymentPurpose *NONNULL_PTR obj); +void NodeFeatures_set_upfront_shutdown_script_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentPurpose from a byte array, created by PaymentPurpose_write + * Checks if this feature is supported. */ -struct LDKCResult_PaymentPurposeDecodeErrorZ PaymentPurpose_read(struct LDKu8slice ser); +MUST_USE_RES bool NodeFeatures_supports_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ClaimedHTLC, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void ClaimedHTLC_free(struct LDKClaimedHTLC this_obj); +MUST_USE_RES bool InitFeatures_requires_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The `channel_id` of the channel over which the HTLC was received. + * Checks if this feature is required. */ -struct LDKChannelId ClaimedHTLC_get_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_requires_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The `channel_id` of the channel over which the HTLC was received. + * Set this feature as optional. */ -void ClaimedHTLC_set_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); +void InitFeatures_set_gossip_queries_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The `user_channel_id` of the channel over which the HTLC was received. This is the value - * passed in to [`ChannelManager::create_channel`] for outbound channels, or to - * [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for an inbound channel. - * - * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This - * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but - * was not actually claimed until after upgrading.) - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * Set this feature as required. */ -struct LDKU128 ClaimedHTLC_get_user_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +void InitFeatures_set_gossip_queries_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The `user_channel_id` of the channel over which the HTLC was received. This is the value - * passed in to [`ChannelManager::create_channel`] for outbound channels, or to - * [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for an inbound channel. - * - * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This - * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but - * was not actually claimed until after upgrading.) - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * Checks if this feature is supported. */ -void ClaimedHTLC_set_user_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKU128 val); +MUST_USE_RES bool InitFeatures_supports_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The block height at which this HTLC expires. + * Set this feature as optional. */ -uint32_t ClaimedHTLC_get_cltv_expiry(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +void NodeFeatures_set_gossip_queries_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The block height at which this HTLC expires. + * Set this feature as required. */ -void ClaimedHTLC_set_cltv_expiry(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint32_t val); +void NodeFeatures_set_gossip_queries_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The amount (in msats) of this part of an MPP. + * Checks if this feature is supported. */ -uint64_t ClaimedHTLC_get_value_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The amount (in msats) of this part of an MPP. + * Checks if this feature is required. */ -void ClaimedHTLC_set_value_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES bool InitFeatures_requires_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The extra fee our counterparty skimmed off the top of this HTLC, if any. - * - * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to - * 0.0.119. + * Checks if this feature is required. */ -uint64_t ClaimedHTLC_get_counterparty_skimmed_fee_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_requires_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The extra fee our counterparty skimmed off the top of this HTLC, if any. - * - * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to - * 0.0.119. + * Set this feature as optional. */ -void ClaimedHTLC_set_counterparty_skimmed_fee_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t val); +void InitFeatures_set_variable_length_onion_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new ClaimedHTLC given each field + * Set this feature as required. */ -MUST_USE_RES struct LDKClaimedHTLC ClaimedHTLC_new(struct LDKChannelId channel_id_arg, struct LDKU128 user_channel_id_arg, uint32_t cltv_expiry_arg, uint64_t value_msat_arg, uint64_t counterparty_skimmed_fee_msat_arg); +void InitFeatures_set_variable_length_onion_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ClaimedHTLC + * Checks if this feature is supported. */ -struct LDKClaimedHTLC ClaimedHTLC_clone(const struct LDKClaimedHTLC *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_supports_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two ClaimedHTLCs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Set this feature as optional. */ -bool ClaimedHTLC_eq(const struct LDKClaimedHTLC *NONNULL_PTR a, const struct LDKClaimedHTLC *NONNULL_PTR b); +void NodeFeatures_set_variable_length_onion_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read + * Set this feature as required. */ -struct LDKCVec_u8Z ClaimedHTLC_write(const struct LDKClaimedHTLC *NONNULL_PTR obj); +void NodeFeatures_set_variable_length_onion_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write + * Checks if this feature is supported. */ -struct LDKCResult_ClaimedHTLCDecodeErrorZ ClaimedHTLC_read(struct LDKu8slice ser); +MUST_USE_RES bool NodeFeatures_supports_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PathFailure + * Set this feature as optional. */ -void PathFailure_free(struct LDKPathFailure this_ptr); +void Bolt11InvoiceFeatures_set_variable_length_onion_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PathFailure + * Set this feature as required. */ -struct LDKPathFailure PathFailure_clone(const struct LDKPathFailure *NONNULL_PTR orig); +void Bolt11InvoiceFeatures_set_variable_length_onion_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InitialSend-variant PathFailure + * Checks if this feature is supported. */ -struct LDKPathFailure PathFailure_initial_send(struct LDKAPIError err); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OnPath-variant PathFailure + * Checks if this feature is required. */ -struct LDKPathFailure PathFailure_on_path(struct LDKCOption_NetworkUpdateZ network_update); +MUST_USE_RES bool InitFeatures_requires_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two PathFailures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if this feature is required. */ -bool PathFailure_eq(const struct LDKPathFailure *NONNULL_PTR a, const struct LDKPathFailure *NONNULL_PTR b); +MUST_USE_RES bool NodeFeatures_requires_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the PathFailure object into a byte array which can be read by PathFailure_read + * Checks if this feature is required. */ -struct LDKCVec_u8Z PathFailure_write(const struct LDKPathFailure *NONNULL_PTR obj); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Read a PathFailure from a byte array, created by PathFailure_write + * Set this feature as optional. */ -struct LDKCResult_COption_PathFailureZDecodeErrorZ PathFailure_read(struct LDKu8slice ser); +void InitFeatures_set_static_remote_key_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ClosureReason + * Set this feature as required. */ -void ClosureReason_free(struct LDKClosureReason this_ptr); +void InitFeatures_set_static_remote_key_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ClosureReason + * Checks if this feature is supported. */ -struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_supports_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason + * Set this feature as optional. */ -struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKUntrustedString peer_msg); +void NodeFeatures_set_static_remote_key_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HolderForceClosed-variant ClosureReason + * Set this feature as required. */ -struct LDKClosureReason ClosureReason_holder_force_closed(struct LDKCOption_boolZ broadcasted_latest_txn); +void NodeFeatures_set_static_remote_key_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new LegacyCooperativeClosure-variant ClosureReason + * Checks if this feature is supported. */ -struct LDKClosureReason ClosureReason_legacy_cooperative_closure(void); +MUST_USE_RES bool NodeFeatures_supports_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CounterpartyInitiatedCooperativeClosure-variant ClosureReason + * Set this feature as optional. */ -struct LDKClosureReason ClosureReason_counterparty_initiated_cooperative_closure(void); +void ChannelTypeFeatures_set_static_remote_key_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new LocallyInitiatedCooperativeClosure-variant ClosureReason + * Set this feature as required. */ -struct LDKClosureReason ClosureReason_locally_initiated_cooperative_closure(void); +void ChannelTypeFeatures_set_static_remote_key_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason + * Checks if this feature is supported. */ -struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); +MUST_USE_RES bool ChannelTypeFeatures_supports_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FundingTimedOut-variant ClosureReason + * Checks if this feature is required. */ -struct LDKClosureReason ClosureReason_funding_timed_out(void); +MUST_USE_RES bool InitFeatures_requires_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ProcessingError-variant ClosureReason + * Checks if this feature is required. */ -struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); +MUST_USE_RES bool NodeFeatures_requires_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new DisconnectedPeer-variant ClosureReason + * Checks if this feature is required. */ -struct LDKClosureReason ClosureReason_disconnected_peer(void); +MUST_USE_RES bool ChannelTypeFeatures_requires_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason + * Set this feature as optional. */ -struct LDKClosureReason ClosureReason_outdated_channel_manager(void); +void InitFeatures_set_payment_secret_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason + * Set this feature as required. */ -struct LDKClosureReason ClosureReason_counterparty_coop_closed_unfunded_channel(void); +void InitFeatures_set_payment_secret_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FundingBatchClosure-variant ClosureReason + * Checks if this feature is supported. */ -struct LDKClosureReason ClosureReason_funding_batch_closure(void); +MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HTLCsTimedOut-variant ClosureReason + * Set this feature as optional. */ -struct LDKClosureReason ClosureReason_htlcs_timed_out(void); +void NodeFeatures_set_payment_secret_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PeerFeerateTooLow-variant ClosureReason + * Set this feature as required. */ -struct LDKClosureReason ClosureReason_peer_feerate_too_low(uint32_t peer_feerate_sat_per_kw, uint32_t required_feerate_sat_per_kw); +void NodeFeatures_set_payment_secret_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two ClosureReasons contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if this feature is supported. */ -bool ClosureReason_eq(const struct LDKClosureReason *NONNULL_PTR a, const struct LDKClosureReason *NONNULL_PTR b); +MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Get the string representation of a ClosureReason object + * Set this feature as optional. */ -struct LDKStr ClosureReason_to_str(const struct LDKClosureReason *NONNULL_PTR o); +void Bolt11InvoiceFeatures_set_payment_secret_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read + * Set this feature as required. */ -struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); +void Bolt11InvoiceFeatures_set_payment_secret_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Read a ClosureReason from a byte array, created by ClosureReason_write + * Checks if this feature is supported. */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the HTLCDestination + * Checks if this feature is required. */ -void HTLCDestination_free(struct LDKHTLCDestination this_ptr); +MUST_USE_RES bool InitFeatures_requires_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the HTLCDestination + * Checks if this feature is required. */ -struct LDKHTLCDestination HTLCDestination_clone(const struct LDKHTLCDestination *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_requires_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new NextHopChannel-variant HTLCDestination + * Checks if this feature is required. */ -struct LDKHTLCDestination HTLCDestination_next_hop_channel(struct LDKPublicKey node_id, struct LDKChannelId channel_id); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UnknownNextHop-variant HTLCDestination + * Set this feature as optional. */ -struct LDKHTLCDestination HTLCDestination_unknown_next_hop(uint64_t requested_forward_scid); +void InitFeatures_set_basic_mpp_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidForward-variant HTLCDestination + * Set this feature as required. */ -struct LDKHTLCDestination HTLCDestination_invalid_forward(uint64_t requested_forward_scid); +void InitFeatures_set_basic_mpp_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidOnion-variant HTLCDestination + * Checks if this feature is supported. */ -struct LDKHTLCDestination HTLCDestination_invalid_onion(void); +MUST_USE_RES bool InitFeatures_supports_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FailedPayment-variant HTLCDestination + * Set this feature as optional. */ -struct LDKHTLCDestination HTLCDestination_failed_payment(struct LDKThirtyTwoBytes payment_hash); +void NodeFeatures_set_basic_mpp_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two HTLCDestinations contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as required. */ -bool HTLCDestination_eq(const struct LDKHTLCDestination *NONNULL_PTR a, const struct LDKHTLCDestination *NONNULL_PTR b); +void NodeFeatures_set_basic_mpp_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z HTLCDestination_write(const struct LDKHTLCDestination *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_supports_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a HTLCDestination from a byte array, created by HTLCDestination_write + * Set this feature as optional. */ -struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(struct LDKu8slice ser); +void Bolt11InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentFailureReason + * Set this feature as required. */ -enum LDKPaymentFailureReason PaymentFailureReason_clone(const enum LDKPaymentFailureReason *NONNULL_PTR orig); +void Bolt11InvoiceFeatures_set_basic_mpp_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new RecipientRejected-variant PaymentFailureReason + * Checks if this feature is supported. */ -enum LDKPaymentFailureReason PaymentFailureReason_recipient_rejected(void); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UserAbandoned-variant PaymentFailureReason + * Set this feature as optional. */ -enum LDKPaymentFailureReason PaymentFailureReason_user_abandoned(void); +void Bolt12InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason + * Set this feature as required. */ -enum LDKPaymentFailureReason PaymentFailureReason_retries_exhausted(void); +void Bolt12InvoiceFeatures_set_basic_mpp_required(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentExpired-variant PaymentFailureReason + * Checks if this feature is supported. */ -enum LDKPaymentFailureReason PaymentFailureReason_payment_expired(void); +MUST_USE_RES bool Bolt12InvoiceFeatures_supports_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new RouteNotFound-variant PaymentFailureReason + * Checks if this feature is required. */ -enum LDKPaymentFailureReason PaymentFailureReason_route_not_found(void); +MUST_USE_RES bool InitFeatures_requires_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UnexpectedError-variant PaymentFailureReason + * Checks if this feature is required. */ -enum LDKPaymentFailureReason PaymentFailureReason_unexpected_error(void); +MUST_USE_RES bool NodeFeatures_requires_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UnknownRequiredFeatures-variant PaymentFailureReason + * Checks if this feature is required. */ -enum LDKPaymentFailureReason PaymentFailureReason_unknown_required_features(void); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvoiceRequestExpired-variant PaymentFailureReason + * Checks if this feature is required. */ -enum LDKPaymentFailureReason PaymentFailureReason_invoice_request_expired(void); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvoiceRequestRejected-variant PaymentFailureReason + * Set this feature as optional. */ -enum LDKPaymentFailureReason PaymentFailureReason_invoice_request_rejected(void); +void InitFeatures_set_wumbo_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BlindedPathCreationFailed-variant PaymentFailureReason + * Set this feature as required. */ -enum LDKPaymentFailureReason PaymentFailureReason_blinded_path_creation_failed(void); +void InitFeatures_set_wumbo_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two PaymentFailureReasons contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if this feature is supported. */ -bool PaymentFailureReason_eq(const enum LDKPaymentFailureReason *NONNULL_PTR a, const enum LDKPaymentFailureReason *NONNULL_PTR b); +MUST_USE_RES bool InitFeatures_supports_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read + * Set this feature as optional. */ -struct LDKCVec_u8Z PaymentFailureReason_write(const enum LDKPaymentFailureReason *NONNULL_PTR obj); +void NodeFeatures_set_wumbo_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write + * Set this feature as required. */ -struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ PaymentFailureReason_read(struct LDKu8slice ser); +void NodeFeatures_set_wumbo_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the InboundChannelFunds + * Checks if this feature is supported. */ -void InboundChannelFunds_free(struct LDKInboundChannelFunds this_ptr); +MUST_USE_RES bool NodeFeatures_supports_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the InboundChannelFunds + * Checks if this feature is required. */ -struct LDKInboundChannelFunds InboundChannelFunds_clone(const struct LDKInboundChannelFunds *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_requires_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PushMsat-variant InboundChannelFunds + * Checks if this feature is required. */ -struct LDKInboundChannelFunds InboundChannelFunds_push_msat(uint64_t a); +MUST_USE_RES bool NodeFeatures_requires_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new DualFunded-variant InboundChannelFunds + * Set this feature as optional. */ -struct LDKInboundChannelFunds InboundChannelFunds_dual_funded(void); +void InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two InboundChannelFundss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as required. */ -bool InboundChannelFunds_eq(const struct LDKInboundChannelFunds *NONNULL_PTR a, const struct LDKInboundChannelFunds *NONNULL_PTR b); +void InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Event + * Checks if this feature is supported. */ -void Event_free(struct LDKEvent this_ptr); +MUST_USE_RES bool InitFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the Event + * Set this feature as optional. */ -struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); +void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FundingGenerationReady-variant Event + * Set this feature as required. */ -struct LDKEvent Event_funding_generation_ready(struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t channel_value_satoshis, struct LDKCVec_u8Z output_script, struct LDKU128 user_channel_id); +void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FundingTxBroadcastSafe-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_funding_tx_broadcast_safe(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKOutPoint funding_txo, struct LDKPublicKey counterparty_node_id, struct LDKChannelId former_temporary_channel_id); +MUST_USE_RES bool NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentClaimable-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_payment_claimable(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields onion_fields, uint64_t amount_msat, uint64_t counterparty_skimmed_fee_msat, struct LDKPaymentPurpose purpose, struct LDKChannelId via_channel_id, struct LDKCOption_U128Z via_user_channel_id, struct LDKCOption_u32Z claim_deadline, struct LDKCOption_ThirtyTwoBytesZ payment_id); +void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentClaimed-variant Event + * Set this feature as required. */ -struct LDKEvent Event_payment_claimed(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, uint64_t amount_msat, struct LDKPaymentPurpose purpose, struct LDKCVec_ClaimedHTLCZ htlcs, struct LDKCOption_u64Z sender_intended_total_msat, struct LDKRecipientOnionFields onion_fields, struct LDKCOption_ThirtyTwoBytesZ payment_id); +void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ConnectionNeeded-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_connection_needed(struct LDKPublicKey node_id, struct LDKCVec_SocketAddressZ addresses); +MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvoiceReceived-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_invoice_received(struct LDKThirtyTwoBytes payment_id, struct LDKBolt12Invoice invoice, struct LDKCOption_OffersContextZ context, struct LDKResponder responder); +MUST_USE_RES bool InitFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentSent-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_payment_sent(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); +MUST_USE_RES bool NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentFailed-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKCOption_PaymentFailureReasonZ reason); +MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentPathSuccessful-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKPath path); +void InitFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentPathFailed-variant Event + * Set this feature as required. */ -struct LDKEvent Event_payment_path_failed(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKPathFailure failure, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); +void InitFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ProbeSuccessful-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_probe_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path); +MUST_USE_RES bool InitFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ProbeFailed-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_probe_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); +void NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PendingHTLCsForwardable-variant Event + * Set this feature as required. */ -struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); +void NodeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HTLCIntercepted-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_htlcintercepted(struct LDKThirtyTwoBytes intercept_id, uint64_t requested_next_hop_scid, struct LDKThirtyTwoBytes payment_hash, uint64_t inbound_amount_msat, uint64_t expected_outbound_amount_msat); +MUST_USE_RES bool NodeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SpendableOutputs-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs, struct LDKChannelId channel_id); +void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentForwarded-variant Event + * Set this feature as required. */ -struct LDKEvent Event_payment_forwarded(struct LDKChannelId prev_channel_id, struct LDKChannelId next_channel_id, struct LDKCOption_U128Z prev_user_channel_id, struct LDKCOption_U128Z next_user_channel_id, struct LDKPublicKey prev_node_id, struct LDKPublicKey next_node_id, struct LDKCOption_u64Z total_fee_earned_msat, struct LDKCOption_u64Z skimmed_fee_msat, bool claim_from_onchain_tx, struct LDKCOption_u64Z outbound_amount_forwarded_msat); +void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelPending-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_channel_pending(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKChannelId former_temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKOutPoint funding_txo, struct LDKChannelTypeFeatures channel_type); +MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelReady-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_channel_ready(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKChannelTypeFeatures channel_type); +MUST_USE_RES bool InitFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelClosed-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_channel_closed(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKClosureReason reason, struct LDKPublicKey counterparty_node_id, struct LDKCOption_u64Z channel_capacity_sats, struct LDKOutPoint channel_funding_txo, struct LDKCOption_u64Z last_local_balance_msat); +MUST_USE_RES bool NodeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new DiscardFunding-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_discard_funding(struct LDKChannelId channel_id, struct LDKFundingInfo funding_info); +MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OpenChannelRequest-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_open_channel_request(struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, struct LDKInboundChannelFunds channel_negotiation_type, struct LDKChannelTypeFeatures channel_type, bool is_announced, struct LDKChannelParameters params); +void InitFeatures_set_route_blinding_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HTLCHandlingFailed-variant Event + * Set this feature as required. */ -struct LDKEvent Event_htlchandling_failed(struct LDKChannelId prev_channel_id, struct LDKHTLCDestination failed_next_destination); +void InitFeatures_set_route_blinding_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BumpTransaction-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_bump_transaction(struct LDKBumpTransactionEvent a); +MUST_USE_RES bool InitFeatures_supports_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OnionMessageIntercepted-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_onion_message_intercepted(struct LDKPublicKey peer_node_id, struct LDKOnionMessage message); +void NodeFeatures_set_route_blinding_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OnionMessagePeerConnected-variant Event + * Set this feature as required. */ -struct LDKEvent Event_onion_message_peer_connected(struct LDKPublicKey peer_node_id); +void NodeFeatures_set_route_blinding_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two Events contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if this feature is supported. */ -bool Event_eq(const struct LDKEvent *NONNULL_PTR a, const struct LDKEvent *NONNULL_PTR b); +MUST_USE_RES bool NodeFeatures_supports_route_blinding(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the Event object into a byte array which can be read by Event_read + * Checks if this feature is required. */ -struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); +MUST_USE_RES bool InitFeatures_requires_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a Event from a byte array, created by Event_write + * Checks if this feature is required. */ -struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser); +MUST_USE_RES bool NodeFeatures_requires_route_blinding(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the MessageSendEvent + * Set this feature as optional. */ -void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); +void InitFeatures_set_shutdown_any_segwit_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); +void InitFeatures_set_shutdown_any_segwit_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg); +MUST_USE_RES bool InitFeatures_supports_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendAcceptChannelV2-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_accept_channel_v2(struct LDKPublicKey node_id, struct LDKAcceptChannelV2 msg); +void NodeFeatures_set_shutdown_any_segwit_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg); +void NodeFeatures_set_shutdown_any_segwit_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendOpenChannelV2-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_open_channel_v2(struct LDKPublicKey node_id, struct LDKOpenChannelV2 msg); +MUST_USE_RES bool NodeFeatures_supports_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg); +MUST_USE_RES bool InitFeatures_requires_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg); +MUST_USE_RES bool NodeFeatures_requires_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendStfu-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_stfu(struct LDKPublicKey node_id, struct LDKStfu msg); +void InitFeatures_set_dual_fund_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendSpliceInit-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_splice_init(struct LDKPublicKey node_id, struct LDKSpliceInit msg); +void InitFeatures_set_dual_fund_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendSpliceAck-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_splice_ack(struct LDKPublicKey node_id, struct LDKSpliceAck msg); +MUST_USE_RES bool InitFeatures_supports_dual_fund(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendSpliceLocked-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_splice_locked(struct LDKPublicKey node_id, struct LDKSpliceLocked msg); +void NodeFeatures_set_dual_fund_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAddInput-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_add_input(struct LDKPublicKey node_id, struct LDKTxAddInput msg); +void NodeFeatures_set_dual_fund_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAddOutput-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_add_output(struct LDKPublicKey node_id, struct LDKTxAddOutput msg); +MUST_USE_RES bool NodeFeatures_supports_dual_fund(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxRemoveInput-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_input(struct LDKPublicKey node_id, struct LDKTxRemoveInput msg); +MUST_USE_RES bool InitFeatures_requires_dual_fund(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxRemoveOutput-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_output(struct LDKPublicKey node_id, struct LDKTxRemoveOutput msg); +MUST_USE_RES bool NodeFeatures_requires_dual_fund(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxComplete-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_complete(struct LDKPublicKey node_id, struct LDKTxComplete msg); +void InitFeatures_set_taproot_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxSignatures-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_signatures(struct LDKPublicKey node_id, struct LDKTxSignatures msg); +void InitFeatures_set_taproot_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxInitRbf-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_init_rbf(struct LDKPublicKey node_id, struct LDKTxInitRbf msg); +MUST_USE_RES bool InitFeatures_supports_taproot(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAckRbf-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_ack_rbf(struct LDKPublicKey node_id, struct LDKTxAckRbf msg); +void NodeFeatures_set_taproot_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAbort-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_abort(struct LDKPublicKey node_id, struct LDKTxAbort msg); +void NodeFeatures_set_taproot_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelReady-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_ready(struct LDKPublicKey node_id, struct LDKChannelReady msg); +MUST_USE_RES bool NodeFeatures_supports_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg); +void ChannelTypeFeatures_set_taproot_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates); +void ChannelTypeFeatures_set_taproot_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg); +MUST_USE_RES bool ChannelTypeFeatures_supports_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg); +MUST_USE_RES bool InitFeatures_requires_taproot(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendShutdown-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg); +MUST_USE_RES bool NodeFeatures_requires_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg); +MUST_USE_RES bool ChannelTypeFeatures_requires_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_announcement(struct LDKPublicKey node_id, struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); +void InitFeatures_set_onion_messages_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); +void InitFeatures_set_onion_messages_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_update(struct LDKChannelUpdate msg); +MUST_USE_RES bool InitFeatures_supports_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg); +void NodeFeatures_set_onion_messages_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublicKey node_id, struct LDKChannelUpdate msg); +void NodeFeatures_set_onion_messages_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HandleError-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action); +MUST_USE_RES bool NodeFeatures_supports_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); +MUST_USE_RES bool InitFeatures_requires_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg); +MUST_USE_RES bool NodeFeatures_requires_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg); +void InitFeatures_set_channel_type_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct LDKPublicKey node_id, struct LDKGossipTimestampFilter msg); +void InitFeatures_set_channel_type_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Checks if this feature is supported. */ -void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); +MUST_USE_RES bool InitFeatures_supports_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Set this feature as optional. */ -void EventsProvider_free(struct LDKEventsProvider this_ptr); +void NodeFeatures_set_channel_type_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ReplayEvent, if is_owned is set and inner is non-NULL. + * Set this feature as required. */ -void ReplayEvent_free(struct LDKReplayEvent this_obj); +void NodeFeatures_set_channel_type_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new ReplayEvent given each field + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKReplayEvent ReplayEvent_new(void); +MUST_USE_RES bool NodeFeatures_supports_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ReplayEvent + * Checks if this feature is required. */ -struct LDKReplayEvent ReplayEvent_clone(const struct LDKReplayEvent *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_requires_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Checks if this feature is required. */ -void EventHandler_free(struct LDKEventHandler this_ptr); +MUST_USE_RES bool NodeFeatures_requires_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the AnchorDescriptor, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void AnchorDescriptor_free(struct LDKAnchorDescriptor this_obj); +void InitFeatures_set_scid_privacy_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The parameters required to derive the signer for the anchor input. + * Set this feature as required. */ -struct LDKChannelDerivationParameters AnchorDescriptor_get_channel_derivation_parameters(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); +void InitFeatures_set_scid_privacy_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The parameters required to derive the signer for the anchor input. + * Checks if this feature is supported. */ -void AnchorDescriptor_set_channel_derivation_parameters(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); +MUST_USE_RES bool InitFeatures_supports_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The transaction input's outpoint corresponding to the commitment transaction's anchor - * output. + * Set this feature as optional. */ -struct LDKOutPoint AnchorDescriptor_get_outpoint(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); +void NodeFeatures_set_scid_privacy_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The transaction input's outpoint corresponding to the commitment transaction's anchor - * output. + * Set this feature as required. */ -void AnchorDescriptor_set_outpoint(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void NodeFeatures_set_scid_privacy_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new AnchorDescriptor given each field + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKAnchorDescriptor AnchorDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKOutPoint outpoint_arg); +MUST_USE_RES bool NodeFeatures_supports_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the AnchorDescriptor + * Set this feature as optional. */ -struct LDKAnchorDescriptor AnchorDescriptor_clone(const struct LDKAnchorDescriptor *NONNULL_PTR orig); +void ChannelTypeFeatures_set_scid_privacy_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Checks if two AnchorDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Set this feature as required. */ -bool AnchorDescriptor_eq(const struct LDKAnchorDescriptor *NONNULL_PTR a, const struct LDKAnchorDescriptor *NONNULL_PTR b); +void ChannelTypeFeatures_set_scid_privacy_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Returns the UTXO to be spent by the anchor input, which can be obtained via - * [`Self::unsigned_tx_input`]. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKTxOut AnchorDescriptor_previous_utxo(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); +MUST_USE_RES bool ChannelTypeFeatures_supports_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Returns the unsigned transaction input spending the anchor output in the commitment - * transaction. + * Checks if this feature is required. */ -MUST_USE_RES struct LDKTxIn AnchorDescriptor_unsigned_tx_input(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_requires_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Returns the witness script of the anchor output in the commitment transaction. + * Checks if this feature is required. */ -MUST_USE_RES struct LDKCVec_u8Z AnchorDescriptor_witness_script(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_requires_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns the fully signed witness required to spend the anchor output in the commitment - * transaction. + * Checks if this feature is required. */ -MUST_USE_RES struct LDKWitness AnchorDescriptor_tx_input_witness(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature); +MUST_USE_RES bool ChannelTypeFeatures_requires_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Derives the channel signer required to sign the anchor input. + * Set this feature as optional. */ -MUST_USE_RES struct LDKEcdsaChannelSigner AnchorDescriptor_derive_channel_signer(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); +void Bolt11InvoiceFeatures_set_payment_metadata_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the BumpTransactionEvent + * Set this feature as required. */ -void BumpTransactionEvent_free(struct LDKBumpTransactionEvent this_ptr); +void Bolt11InvoiceFeatures_set_payment_metadata_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the BumpTransactionEvent + * Checks if this feature is supported. */ -struct LDKBumpTransactionEvent BumpTransactionEvent_clone(const struct LDKBumpTransactionEvent *NONNULL_PTR orig); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelClose-variant BumpTransactionEvent + * Checks if this feature is required. */ -struct LDKBumpTransactionEvent BumpTransactionEvent_channel_close(struct LDKChannelId channel_id, struct LDKPublicKey counterparty_node_id, struct LDKThirtyTwoBytes claim_id, uint32_t package_target_feerate_sat_per_1000_weight, struct LDKTransaction commitment_tx, uint64_t commitment_tx_fee_satoshis, struct LDKAnchorDescriptor anchor_descriptor, struct LDKCVec_HTLCOutputInCommitmentZ pending_htlcs); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent + * Set this feature as optional. */ -struct LDKBumpTransactionEvent BumpTransactionEvent_htlcresolution(struct LDKChannelId channel_id, struct LDKPublicKey counterparty_node_id, struct LDKThirtyTwoBytes claim_id, uint32_t target_feerate_sat_per_1000_weight, struct LDKCVec_HTLCDescriptorZ htlc_descriptors, uint32_t tx_lock_time); +void InitFeatures_set_zero_conf_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two BumpTransactionEvents contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as required. */ -bool BumpTransactionEvent_eq(const struct LDKBumpTransactionEvent *NONNULL_PTR a, const struct LDKBumpTransactionEvent *NONNULL_PTR b); +void InitFeatures_set_zero_conf_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Input, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void Input_free(struct LDKInput this_obj); +MUST_USE_RES bool InitFeatures_supports_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The unique identifier of the input. + * Set this feature as optional. */ -struct LDKOutPoint Input_get_outpoint(const struct LDKInput *NONNULL_PTR this_ptr); +void NodeFeatures_set_zero_conf_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The unique identifier of the input. + * Set this feature as required. */ -void Input_set_outpoint(struct LDKInput *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void NodeFeatures_set_zero_conf_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The UTXO being spent by the input. + * Checks if this feature is supported. */ -struct LDKTxOut Input_get_previous_utxo(const struct LDKInput *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The UTXO being spent by the input. + * Set this feature as optional. */ -void Input_set_previous_utxo(struct LDKInput *NONNULL_PTR this_ptr, struct LDKTxOut val); +void ChannelTypeFeatures_set_zero_conf_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and - * [`TxIn::witness`], each with their lengths included, required to satisfy the output's - * script. + * Set this feature as required. */ -uint64_t Input_get_satisfaction_weight(const struct LDKInput *NONNULL_PTR this_ptr); +void ChannelTypeFeatures_set_zero_conf_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and - * [`TxIn::witness`], each with their lengths included, required to satisfy the output's - * script. + * Checks if this feature is supported. */ -void Input_set_satisfaction_weight(struct LDKInput *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES bool ChannelTypeFeatures_supports_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new Input given each field + * Checks if this feature is required. */ -MUST_USE_RES struct LDKInput Input_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut previous_utxo_arg, uint64_t satisfaction_weight_arg); +MUST_USE_RES bool InitFeatures_requires_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the Input + * Checks if this feature is required. */ -struct LDKInput Input_clone(const struct LDKInput *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_requires_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the Input. + * Checks if this feature is required. */ -uint64_t Input_hash(const struct LDKInput *NONNULL_PTR o); +MUST_USE_RES bool ChannelTypeFeatures_requires_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Checks if two Inputs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Set this feature as optional. */ -bool Input_eq(const struct LDKInput *NONNULL_PTR a, const struct LDKInput *NONNULL_PTR b); +void NodeFeatures_set_keysend_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Utxo, if is_owned is set and inner is non-NULL. + * Set this feature as required. */ -void Utxo_free(struct LDKUtxo this_obj); +void NodeFeatures_set_keysend_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The unique identifier of the output. + * Checks if this feature is supported. */ -struct LDKOutPoint Utxo_get_outpoint(const struct LDKUtxo *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The unique identifier of the output. + * Checks if this feature is required. */ -void Utxo_set_outpoint(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKOutPoint val); +MUST_USE_RES bool NodeFeatures_requires_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The output to spend. + * Set this feature as optional. */ -struct LDKTxOut Utxo_get_output(const struct LDKUtxo *NONNULL_PTR this_ptr); +void InitFeatures_set_trampoline_routing_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The output to spend. + * Set this feature as required. */ -void Utxo_set_output(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKTxOut val); +void InitFeatures_set_trampoline_routing_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each - * with their lengths included, required to satisfy the output's script. The weight consumed by - * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. + * Checks if this feature is supported. */ -uint64_t Utxo_get_satisfaction_weight(const struct LDKUtxo *NONNULL_PTR this_ptr); +MUST_USE_RES bool InitFeatures_supports_trampoline_routing(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each - * with their lengths included, required to satisfy the output's script. The weight consumed by - * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. + * Set this feature as optional. */ -void Utxo_set_satisfaction_weight(struct LDKUtxo *NONNULL_PTR this_ptr, uint64_t val); +void NodeFeatures_set_trampoline_routing_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new Utxo given each field + * Set this feature as required. */ -MUST_USE_RES struct LDKUtxo Utxo_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, uint64_t satisfaction_weight_arg); +void NodeFeatures_set_trampoline_routing_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the Utxo + * Checks if this feature is supported. */ -struct LDKUtxo Utxo_clone(const struct LDKUtxo *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_supports_trampoline_routing(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the Utxo. + * Set this feature as optional. */ -uint64_t Utxo_hash(const struct LDKUtxo *NONNULL_PTR o); +void Bolt11InvoiceFeatures_set_trampoline_routing_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Checks if two Utxos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Set this feature as required. */ -bool Utxo_eq(const struct LDKUtxo *NONNULL_PTR a, const struct LDKUtxo *NONNULL_PTR b); +void Bolt11InvoiceFeatures_set_trampoline_routing_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKUtxo Utxo_new_p2pkh(struct LDKOutPoint outpoint, uint64_t value, const uint8_t (*pubkey_hash)[20]); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_trampoline_routing(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the CoinSelection, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void CoinSelection_free(struct LDKCoinSelection this_obj); +void Bolt12InvoiceFeatures_set_trampoline_routing_optional(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction - * requiring additional fees. + * Set this feature as required. + */ +void Bolt12InvoiceFeatures_set_trampoline_routing_required(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); + +/** + * Checks if this feature is supported. */ -struct LDKCVec_UtxoZ CoinSelection_get_confirmed_utxos(const struct LDKCoinSelection *NONNULL_PTR this_ptr); +MUST_USE_RES bool Bolt12InvoiceFeatures_supports_trampoline_routing(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction - * requiring additional fees. + * Checks if this feature is required. */ -void CoinSelection_set_confirmed_utxos(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCVec_UtxoZ val); +MUST_USE_RES bool InitFeatures_requires_trampoline_routing(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * An additional output tracking whether any change remained after coin selection. This output - * should always have a value above dust for its given `script_pubkey`. It should not be - * spent until the transaction it belongs to confirms to ensure mempool descendant limits are - * not met. This implies no other party should be able to spend it except us. + * Checks if this feature is required. */ -struct LDKCOption_TxOutZ CoinSelection_get_change_output(const struct LDKCoinSelection *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_requires_trampoline_routing(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * An additional output tracking whether any change remained after coin selection. This output - * should always have a value above dust for its given `script_pubkey`. It should not be - * spent until the transaction it belongs to confirms to ensure mempool descendant limits are - * not met. This implies no other party should be able to spend it except us. + * Checks if this feature is required. */ -void CoinSelection_set_change_output(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCOption_TxOutZ val); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_trampoline_routing(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Constructs a new CoinSelection given each field + * Checks if this feature is required. */ -MUST_USE_RES struct LDKCoinSelection CoinSelection_new(struct LDKCVec_UtxoZ confirmed_utxos_arg, struct LDKCOption_TxOutZ change_output_arg); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_trampoline_routing(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the CoinSelection + * Set this feature as optional. */ -struct LDKCoinSelection CoinSelection_clone(const struct LDKCoinSelection *NONNULL_PTR orig); +void NodeFeatures_set_dns_resolution_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Set this feature as required. */ -void CoinSelectionSource_free(struct LDKCoinSelectionSource this_ptr); +void NodeFeatures_set_dns_resolution_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Checks if this feature is supported. */ -void WalletSource_free(struct LDKWalletSource this_ptr); +MUST_USE_RES bool NodeFeatures_supports_dns_resolution(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Wallet, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void Wallet_free(struct LDKWallet this_obj); +MUST_USE_RES bool NodeFeatures_requires_dns_resolution(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns a new instance backed by the given [`WalletSource`] that serves as an implementation - * of [`CoinSelectionSource`]. + * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKWallet Wallet_new(struct LDKWalletSource source, struct LDKLogger logger); +void RoutingFees_free(struct LDKRoutingFees this_obj); /** - * Constructs a new CoinSelectionSource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CoinSelectionSource must be freed before this_arg is + * Flat routing fee in millisatoshis. */ -struct LDKCoinSelectionSource Wallet_as_CoinSelectionSource(const struct LDKWallet *NONNULL_PTR this_arg); +uint32_t RoutingFees_get_base_msat(const struct LDKRoutingFees *NONNULL_PTR this_ptr); /** - * Frees any resources used by the BumpTransactionEventHandler, if is_owned is set and inner is non-NULL. + * Flat routing fee in millisatoshis. */ -void BumpTransactionEventHandler_free(struct LDKBumpTransactionEventHandler this_obj); +void RoutingFees_set_base_msat(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); /** - * Returns a new instance capable of handling [`Event::BumpTransaction`] events. - * - * [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction + * Liquidity-based routing fee in millionths of a routed amount. + * In other words, 10000 is 1%. */ -MUST_USE_RES struct LDKBumpTransactionEventHandler BumpTransactionEventHandler_new(struct LDKBroadcasterInterface broadcaster, struct LDKCoinSelectionSource utxo_source, struct LDKSignerProvider signer_provider, struct LDKLogger logger); +uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *NONNULL_PTR this_ptr); /** - * Handles all variants of [`BumpTransactionEvent`]. + * Liquidity-based routing fee in millionths of a routed amount. + * In other words, 10000 is 1%. */ -void BumpTransactionEventHandler_handle_event(const struct LDKBumpTransactionEventHandler *NONNULL_PTR this_arg, const struct LDKBumpTransactionEvent *NONNULL_PTR event); +void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if two InitFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constructs a new RoutingFees given each field */ -bool InitFeatures_eq(const struct LDKInitFeatures *NONNULL_PTR a, const struct LDKInitFeatures *NONNULL_PTR b); +MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); /** - * Checks if two NodeFeaturess contain equal inner contents. + * Checks if two RoutingFeess contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool NodeFeatures_eq(const struct LDKNodeFeatures *NONNULL_PTR a, const struct LDKNodeFeatures *NONNULL_PTR b); +bool RoutingFees_eq(const struct LDKRoutingFees *NONNULL_PTR a, const struct LDKRoutingFees *NONNULL_PTR b); /** - * Checks if two ChannelFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the RoutingFees */ -bool ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const struct LDKChannelFeatures *NONNULL_PTR b); +struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); /** - * Checks if two Bolt11InvoiceFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Generates a non-cryptographic 64-bit hash of the RoutingFees. */ -bool Bolt11InvoiceFeatures_eq(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR b); +uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o); /** - * Checks if two OfferFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. */ -bool OfferFeatures_eq(const struct LDKOfferFeatures *NONNULL_PTR a, const struct LDKOfferFeatures *NONNULL_PTR b); +void RouteHint_free(struct LDKRouteHint this_obj); + +struct LDKCVec_RouteHintHopZ RouteHint_get_a(const struct LDKRouteHint *NONNULL_PTR this_ptr); + +void RouteHint_set_a(struct LDKRouteHint *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintHopZ val); /** - * Checks if two InvoiceRequestFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constructs a new RouteHint given each field */ -bool InvoiceRequestFeatures_eq(const struct LDKInvoiceRequestFeatures *NONNULL_PTR a, const struct LDKInvoiceRequestFeatures *NONNULL_PTR b); +MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKCVec_RouteHintHopZ a_arg); /** - * Checks if two Bolt12InvoiceFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the RouteHint */ -bool Bolt12InvoiceFeatures_eq(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR b); +struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); /** - * Checks if two BlindedHopFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Generates a non-cryptographic 64-bit hash of the RouteHint. */ -bool BlindedHopFeatures_eq(const struct LDKBlindedHopFeatures *NONNULL_PTR a, const struct LDKBlindedHopFeatures *NONNULL_PTR b); +uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o); /** - * Checks if two ChannelTypeFeaturess contain equal inner contents. + * Checks if two RouteHints contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b); +bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); /** - * Creates a copy of the InitFeatures + * Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. */ -struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); +void RouteHintHop_free(struct LDKRouteHintHop this_obj); /** - * Creates a copy of the NodeFeatures + * The node_id of the non-target end of the route */ -struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); +struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Creates a copy of the ChannelFeatures + * The node_id of the non-target end of the route */ -struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); +void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a copy of the Bolt11InvoiceFeatures + * The short_channel_id of this channel */ -struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_clone(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR orig); +uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Creates a copy of the OfferFeatures + * The short_channel_id of this channel */ -struct LDKOfferFeatures OfferFeatures_clone(const struct LDKOfferFeatures *NONNULL_PTR orig); +void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the InvoiceRequestFeatures + * The fees which must be paid to use this channel */ -struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_clone(const struct LDKInvoiceRequestFeatures *NONNULL_PTR orig); +struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Creates a copy of the Bolt12InvoiceFeatures + * The fees which must be paid to use this channel */ -struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_clone(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR orig); +void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** - * Creates a copy of the BlindedHopFeatures + * The difference in CLTV values between this node and the next node. */ -struct LDKBlindedHopFeatures BlindedHopFeatures_clone(const struct LDKBlindedHopFeatures *NONNULL_PTR orig); +uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Creates a copy of the ChannelTypeFeatures + * The difference in CLTV values between this node and the next node. */ -struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig); +void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val); /** - * Generates a non-cryptographic 64-bit hash of the InitFeatures. + * The minimum value, in msat, which must be relayed to the next hop. */ -uint64_t InitFeatures_hash(const struct LDKInitFeatures *NONNULL_PTR o); +struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the NodeFeatures. + * The minimum value, in msat, which must be relayed to the next hop. */ -uint64_t NodeFeatures_hash(const struct LDKNodeFeatures *NONNULL_PTR o); +void RouteHintHop_set_htlc_minimum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Generates a non-cryptographic 64-bit hash of the ChannelFeatures. + * The maximum value in msat available for routing with a single HTLC. */ -uint64_t ChannelFeatures_hash(const struct LDKChannelFeatures *NONNULL_PTR o); +struct LDKCOption_u64Z RouteHintHop_get_htlc_maximum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures. + * The maximum value in msat available for routing with a single HTLC. */ -uint64_t Bolt11InvoiceFeatures_hash(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR o); +void RouteHintHop_set_htlc_maximum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Generates a non-cryptographic 64-bit hash of the OfferFeatures. + * Constructs a new RouteHintHop given each field */ -uint64_t OfferFeatures_hash(const struct LDKOfferFeatures *NONNULL_PTR o); +MUST_USE_RES struct LDKRouteHintHop RouteHintHop_new(struct LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, struct LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, struct LDKCOption_u64Z htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg); /** - * Generates a non-cryptographic 64-bit hash of the InvoiceRequestFeatures. + * Creates a copy of the RouteHintHop */ -uint64_t InvoiceRequestFeatures_hash(const struct LDKInvoiceRequestFeatures *NONNULL_PTR o); +struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures. + * Generates a non-cryptographic 64-bit hash of the RouteHintHop. */ -uint64_t Bolt12InvoiceFeatures_hash(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR o); +uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o); /** - * Generates a non-cryptographic 64-bit hash of the BlindedHopFeatures. + * Checks if two RouteHintHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint64_t BlindedHopFeatures_hash(const struct LDKBlindedHopFeatures *NONNULL_PTR o); +bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures. + * Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. */ -uint64_t ChannelTypeFeatures_hash(const struct LDKChannelTypeFeatures *NONNULL_PTR o); +void UntrustedString_free(struct LDKUntrustedString this_obj); -/** - * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. - */ -void InitFeatures_free(struct LDKInitFeatures this_obj); +struct LDKStr UntrustedString_get_a(const struct LDKUntrustedString *NONNULL_PTR this_ptr); + +void UntrustedString_set_a(struct LDKUntrustedString *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. + * Constructs a new UntrustedString given each field */ -void NodeFeatures_free(struct LDKNodeFeatures this_obj); +MUST_USE_RES struct LDKUntrustedString UntrustedString_new(struct LDKStr a_arg); /** - * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. + * Creates a copy of the UntrustedString */ -void ChannelFeatures_free(struct LDKChannelFeatures this_obj); +struct LDKUntrustedString UntrustedString_clone(const struct LDKUntrustedString *NONNULL_PTR orig); /** - * Frees any resources used by the Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. + * Checks if two UntrustedStrings contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void Bolt11InvoiceFeatures_free(struct LDKBolt11InvoiceFeatures this_obj); +bool UntrustedString_eq(const struct LDKUntrustedString *NONNULL_PTR a, const struct LDKUntrustedString *NONNULL_PTR b); /** - * Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the UntrustedString. */ -void OfferFeatures_free(struct LDKOfferFeatures this_obj); +uint64_t UntrustedString_hash(const struct LDKUntrustedString *NONNULL_PTR o); /** - * Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. + * Get the string representation of a UntrustedString object */ -void InvoiceRequestFeatures_free(struct LDKInvoiceRequestFeatures this_obj); +struct LDKStr UntrustedString_to_str(const struct LDKUntrustedString *NONNULL_PTR o); /** - * Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. + * Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. */ -void Bolt12InvoiceFeatures_free(struct LDKBolt12InvoiceFeatures this_obj); +void PrintableString_free(struct LDKPrintableString this_obj); + +struct LDKStr PrintableString_get_a(const struct LDKPrintableString *NONNULL_PTR this_ptr); + +void PrintableString_set_a(struct LDKPrintableString *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. + * Constructs a new PrintableString given each field */ -void BlindedHopFeatures_free(struct LDKBlindedHopFeatures this_obj); +MUST_USE_RES struct LDKPrintableString PrintableString_new(struct LDKStr a_arg); /** - * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. + * Get the string representation of a PrintableString object */ -void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); +struct LDKStr PrintableString_to_str(const struct LDKPrintableString *NONNULL_PTR o); /** - * Getting a route for a keysend payment to a private node requires providing the payee's - * features (since they were not announced in a node announcement). However, keysend payments - * don't have an invoice to pull the payee's features from, so this method is provided for use - * when a [`Bolt11InvoiceFeatures`] is required in a route. - * - * MPP keysend is not widely supported yet, so we parameterize support to allow the user to - * choose whether their router should find multi-part routes. + * Frees any resources used by the FilesystemStore, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_for_keysend(bool allow_mpp); +void FilesystemStore_free(struct LDKFilesystemStore this_obj); /** - * Constructs a ChannelTypeFeatures with only static_remotekey set + * Constructs a new [`FilesystemStore`]. */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_only_static_remote_key(void); +MUST_USE_RES struct LDKFilesystemStore FilesystemStore_new(struct LDKStr data_dir); /** - * Constructs a ChannelTypeFeatures with anchors support + * Returns the data directory. */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_anchors_zero_htlc_fee_and_dependencies(void); +MUST_USE_RES struct LDKStr FilesystemStore_get_data_dir(const struct LDKFilesystemStore *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Constructs a new KVStore which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned KVStore must be freed before this_arg is */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); +struct LDKKVStore FilesystemStore_as_KVStore(const struct LDKFilesystemStore *NONNULL_PTR this_arg); /** - * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order - * from most on-the-wire encodings. + * Constructs a new MigratableKVStore which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MigratableKVStore must be freed before this_arg is */ -MUST_USE_RES struct LDKu8slice InitFeatures_le_flags(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKMigratableKVStore FilesystemStore_as_MigratableKVStore(const struct LDKFilesystemStore *NONNULL_PTR this_arg); /** - * Returns true if this `Features` has any optional flags set + * Frees any resources used by the BackgroundProcessor, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_supports_any_optional_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void BackgroundProcessor_free(struct LDKBackgroundProcessor this_obj); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Frees any resources used by the GossipSync */ -MUST_USE_RES bool InitFeatures_requires_unknown_bits_from(const struct LDKInitFeatures *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR other); +void GossipSync_free(struct LDKGossipSync this_ptr); /** - * Returns the set of required features unknown by `other`, as their bit position. + * Utility method to constructs a new P2P-variant GossipSync */ -MUST_USE_RES struct LDKCVec_u64Z InitFeatures_required_unknown_bits_from(const struct LDKInitFeatures *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR other); +struct LDKGossipSync GossipSync_p2_p(const struct LDKP2PGossipSync *NONNULL_PTR a); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Utility method to constructs a new Rapid-variant GossipSync */ -MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKGossipSync GossipSync_rapid(const struct LDKRapidGossipSync *NONNULL_PTR a); /** - * Returns true if this `Features` supports any bits which we do not know of + * Utility method to constructs a new None-variant GossipSync */ -MUST_USE_RES bool InitFeatures_supports_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKGossipSync GossipSync_none(void); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. + * Start a background thread that takes care of responsibilities enumerated in the [top-level + * documentation]. * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * The thread runs indefinitely unless the object is dropped, [`stop`] is called, or + * [`Persister::persist_manager`] returns an error. In case of an error, the error is retrieved by calling + * either [`join`] or [`stop`]. * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * # Data Persistence + * + * [`Persister::persist_manager`] is responsible for writing out the [`ChannelManager`] to disk, and/or + * uploading to one or more backup services. See [`ChannelManager::write`] for writing out a + * [`ChannelManager`]. See the `lightning-persister` crate for LDK's + * provided implementation. + * + * [`Persister::persist_graph`] is responsible for writing out the [`NetworkGraph`] to disk, if + * [`GossipSync`] is supplied. See [`NetworkGraph::write`] for writing out a [`NetworkGraph`]. + * See the `lightning-persister` crate for LDK's provided implementation. + * + * Typically, users should either implement [`Persister::persist_manager`] to never return an + * error or call [`join`] and handle any error that may arise. For the latter case, + * `BackgroundProcessor` must be restarted by calling `start` again after handling the error. + * + * # Event Handling + * + * `event_handler` is responsible for handling events that users should be notified of (e.g., + * payment failed). [`BackgroundProcessor`] may decorate the given [`EventHandler`] with common + * functionality implemented by other handlers. + * * [`P2PGossipSync`] if given will update the [`NetworkGraph`] based on payment failures. + * + * # Rapid Gossip Sync + * + * If rapid gossip sync is meant to run at startup, pass [`RapidGossipSync`] via `gossip_sync` + * to indicate that the [`BackgroundProcessor`] should not prune the [`NetworkGraph`] instance + * until the [`RapidGossipSync`] instance completes its first sync. + * + * [top-level documentation]: BackgroundProcessor + * [`join`]: Self::join + * [`stop`]: Self::stop + * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager + * [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable + * [`Persister::persist_manager`]: lightning::util::persist::Persister::persist_manager + * [`Persister::persist_graph`]: lightning::util::persist::Persister::persist_graph + * [`NetworkGraph`]: lightning::routing::gossip::NetworkGraph + * [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, const struct LDKOnionMessenger *NONNULL_PTR onion_messenger, struct LDKGossipSync gossip_sync, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger, struct LDKCOption_WriteableScoreZ scorer); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. + * Join `BackgroundProcessor`'s thread, returning any error that occurred while persisting + * [`ChannelManager`]. * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). + * # Panics * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * This function panics if the background thread has panicked such as while persisting or + * handling events. + * + * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES struct LDKCResult_NoneIOErrorZ BackgroundProcessor_join(struct LDKBackgroundProcessor this_arg); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. + * Stop `BackgroundProcessor`'s thread, returning any error that occurred while persisting + * [`ChannelManager`]. * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * # Panics * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * This function panics if the background thread has panicked such as while persisting or + * handling events. + * + * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES struct LDKCResult_NoneIOErrorZ BackgroundProcessor_stop(struct LDKBackgroundProcessor this_arg); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Frees any resources used by the Bolt11ParseError, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void Bolt11ParseError_free(struct LDKBolt11ParseError this_obj); /** - * Create a blank Features with no features set + * Checks if two Bolt11ParseErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); +bool Bolt11ParseError_eq(const struct LDKBolt11ParseError *NONNULL_PTR a, const struct LDKBolt11ParseError *NONNULL_PTR b); /** - * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order - * from most on-the-wire encodings. + * Creates a copy of the Bolt11ParseError */ -MUST_USE_RES struct LDKu8slice NodeFeatures_le_flags(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKBolt11ParseError Bolt11ParseError_clone(const struct LDKBolt11ParseError *NONNULL_PTR orig); /** - * Returns true if this `Features` has any optional flags set + * Frees any resources used by the ParseOrSemanticError */ -MUST_USE_RES bool NodeFeatures_supports_any_optional_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void ParseOrSemanticError_free(struct LDKParseOrSemanticError this_ptr); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Creates a copy of the ParseOrSemanticError */ -MUST_USE_RES bool NodeFeatures_requires_unknown_bits_from(const struct LDKNodeFeatures *NONNULL_PTR this_arg, const struct LDKNodeFeatures *NONNULL_PTR other); +struct LDKParseOrSemanticError ParseOrSemanticError_clone(const struct LDKParseOrSemanticError *NONNULL_PTR orig); /** - * Returns the set of required features unknown by `other`, as their bit position. + * Utility method to constructs a new ParseError-variant ParseOrSemanticError */ -MUST_USE_RES struct LDKCVec_u64Z NodeFeatures_required_unknown_bits_from(const struct LDKNodeFeatures *NONNULL_PTR this_arg, const struct LDKNodeFeatures *NONNULL_PTR other); +struct LDKParseOrSemanticError ParseOrSemanticError_parse_error(struct LDKBolt11ParseError a); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Utility method to constructs a new SemanticError-variant ParseOrSemanticError */ -MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKParseOrSemanticError ParseOrSemanticError_semantic_error(enum LDKBolt11SemanticError a); /** - * Returns true if this `Features` supports any bits which we do not know of + * Checks if two ParseOrSemanticErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES bool NodeFeatures_supports_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +bool ParseOrSemanticError_eq(const struct LDKParseOrSemanticError *NONNULL_PTR a, const struct LDKParseOrSemanticError *NONNULL_PTR b); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Frees any resources used by the Bolt11Invoice, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void Bolt11Invoice_free(struct LDKBolt11Invoice this_obj); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Checks if two Bolt11Invoices contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool Bolt11Invoice_eq(const struct LDKBolt11Invoice *NONNULL_PTR a, const struct LDKBolt11Invoice *NONNULL_PTR b); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Creates a copy of the Bolt11Invoice */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKBolt11Invoice Bolt11Invoice_clone(const struct LDKBolt11Invoice *NONNULL_PTR orig); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Generates a non-cryptographic 64-bit hash of the Bolt11Invoice. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +uint64_t Bolt11Invoice_hash(const struct LDKBolt11Invoice *NONNULL_PTR o); /** - * Create a blank Features with no features set + * Frees any resources used by the Bolt11InvoiceDescription */ -MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); +void Bolt11InvoiceDescription_free(struct LDKBolt11InvoiceDescription this_ptr); /** - * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order - * from most on-the-wire encodings. + * Creates a copy of the Bolt11InvoiceDescription */ -MUST_USE_RES struct LDKu8slice ChannelFeatures_le_flags(const struct LDKChannelFeatures *NONNULL_PTR this_arg); +struct LDKBolt11InvoiceDescription Bolt11InvoiceDescription_clone(const struct LDKBolt11InvoiceDescription *NONNULL_PTR orig); /** - * Returns true if this `Features` has any optional flags set + * Utility method to constructs a new Direct-variant Bolt11InvoiceDescription */ -MUST_USE_RES bool ChannelFeatures_supports_any_optional_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); +struct LDKBolt11InvoiceDescription Bolt11InvoiceDescription_direct(struct LDKDescription a); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Utility method to constructs a new Hash-variant Bolt11InvoiceDescription */ -MUST_USE_RES bool ChannelFeatures_requires_unknown_bits_from(const struct LDKChannelFeatures *NONNULL_PTR this_arg, const struct LDKChannelFeatures *NONNULL_PTR other); +struct LDKBolt11InvoiceDescription Bolt11InvoiceDescription_hash(struct LDKSha256 a); /** - * Returns the set of required features unknown by `other`, as their bit position. + * Checks if two Bolt11InvoiceDescriptions contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKCVec_u64Z ChannelFeatures_required_unknown_bits_from(const struct LDKChannelFeatures *NONNULL_PTR this_arg, const struct LDKChannelFeatures *NONNULL_PTR other); +bool Bolt11InvoiceDescription_eq(const struct LDKBolt11InvoiceDescription *NONNULL_PTR a, const struct LDKBolt11InvoiceDescription *NONNULL_PTR b); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Get the string representation of a Bolt11InvoiceDescription object */ -MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); +struct LDKStr Bolt11InvoiceDescription_to_str(const struct LDKBolt11InvoiceDescription *NONNULL_PTR o); /** - * Returns true if this `Features` supports any bits which we do not know of + * Frees any resources used by the SignedRawBolt11Invoice, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool ChannelFeatures_supports_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); +void SignedRawBolt11Invoice_free(struct LDKSignedRawBolt11Invoice this_obj); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Checks if two SignedRawBolt11Invoices contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool SignedRawBolt11Invoice_eq(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR a, const struct LDKSignedRawBolt11Invoice *NONNULL_PTR b); + +/** + * Creates a copy of the SignedRawBolt11Invoice + */ +struct LDKSignedRawBolt11Invoice SignedRawBolt11Invoice_clone(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the SignedRawBolt11Invoice. + */ +uint64_t SignedRawBolt11Invoice_hash(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR o); + +/** + * Frees any resources used by the RawBolt11Invoice, if is_owned is set and inner is non-NULL. + */ +void RawBolt11Invoice_free(struct LDKRawBolt11Invoice this_obj); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * data part */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKRawDataPart RawBolt11Invoice_get_data(const struct LDKRawBolt11Invoice *NONNULL_PTR this_ptr); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * data part */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void RawBolt11Invoice_set_data(struct LDKRawBolt11Invoice *NONNULL_PTR this_ptr, struct LDKRawDataPart val); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Checks if two RawBolt11Invoices contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool RawBolt11Invoice_eq(const struct LDKRawBolt11Invoice *NONNULL_PTR a, const struct LDKRawBolt11Invoice *NONNULL_PTR b); /** - * Create a blank Features with no features set + * Creates a copy of the RawBolt11Invoice */ -MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_empty(void); +struct LDKRawBolt11Invoice RawBolt11Invoice_clone(const struct LDKRawBolt11Invoice *NONNULL_PTR orig); /** - * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order - * from most on-the-wire encodings. + * Generates a non-cryptographic 64-bit hash of the RawBolt11Invoice. */ -MUST_USE_RES struct LDKu8slice Bolt11InvoiceFeatures_le_flags(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +uint64_t RawBolt11Invoice_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR o); /** - * Returns true if this `Features` has any optional flags set + * Frees any resources used by the RawDataPart, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_any_optional_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +void RawDataPart_free(struct LDKRawDataPart this_obj); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * generation time of the invoice */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR other); +struct LDKPositiveTimestamp RawDataPart_get_timestamp(const struct LDKRawDataPart *NONNULL_PTR this_ptr); /** - * Returns the set of required features unknown by `other`, as their bit position. + * generation time of the invoice */ -MUST_USE_RES struct LDKCVec_u64Z Bolt11InvoiceFeatures_required_unknown_bits_from(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR other); +void RawDataPart_set_timestamp(struct LDKRawDataPart *NONNULL_PTR this_ptr, struct LDKPositiveTimestamp val); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if two RawDataParts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +bool RawDataPart_eq(const struct LDKRawDataPart *NONNULL_PTR a, const struct LDKRawDataPart *NONNULL_PTR b); /** - * Returns true if this `Features` supports any bits which we do not know of + * Creates a copy of the RawDataPart */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_unknown_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKRawDataPart RawDataPart_clone(const struct LDKRawDataPart *NONNULL_PTR orig); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Generates a non-cryptographic 64-bit hash of the RawDataPart. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +uint64_t RawDataPart_hash(const struct LDKRawDataPart *NONNULL_PTR o); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Frees any resources used by the PositiveTimestamp, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void PositiveTimestamp_free(struct LDKPositiveTimestamp this_obj); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Checks if two PositiveTimestamps contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool PositiveTimestamp_eq(const struct LDKPositiveTimestamp *NONNULL_PTR a, const struct LDKPositiveTimestamp *NONNULL_PTR b); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Creates a copy of the PositiveTimestamp */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKPositiveTimestamp PositiveTimestamp_clone(const struct LDKPositiveTimestamp *NONNULL_PTR orig); /** - * Create a blank Features with no features set + * Generates a non-cryptographic 64-bit hash of the PositiveTimestamp. */ -MUST_USE_RES struct LDKOfferFeatures OfferFeatures_empty(void); +uint64_t PositiveTimestamp_hash(const struct LDKPositiveTimestamp *NONNULL_PTR o); /** - * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order - * from most on-the-wire encodings. + * Creates a copy of the SiPrefix */ -MUST_USE_RES struct LDKu8slice OfferFeatures_le_flags(const struct LDKOfferFeatures *NONNULL_PTR this_arg); +enum LDKSiPrefix SiPrefix_clone(const enum LDKSiPrefix *NONNULL_PTR orig); /** - * Returns true if this `Features` has any optional flags set + * Utility method to constructs a new Milli-variant SiPrefix */ -MUST_USE_RES bool OfferFeatures_supports_any_optional_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); +enum LDKSiPrefix SiPrefix_milli(void); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Utility method to constructs a new Micro-variant SiPrefix */ -MUST_USE_RES bool OfferFeatures_requires_unknown_bits_from(const struct LDKOfferFeatures *NONNULL_PTR this_arg, const struct LDKOfferFeatures *NONNULL_PTR other); +enum LDKSiPrefix SiPrefix_micro(void); /** - * Returns the set of required features unknown by `other`, as their bit position. + * Utility method to constructs a new Nano-variant SiPrefix */ -MUST_USE_RES struct LDKCVec_u64Z OfferFeatures_required_unknown_bits_from(const struct LDKOfferFeatures *NONNULL_PTR this_arg, const struct LDKOfferFeatures *NONNULL_PTR other); +enum LDKSiPrefix SiPrefix_nano(void); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Utility method to constructs a new Pico-variant SiPrefix */ -MUST_USE_RES bool OfferFeatures_requires_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); +enum LDKSiPrefix SiPrefix_pico(void); /** - * Returns true if this `Features` supports any bits which we do not know of + * Checks if two SiPrefixs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES bool OfferFeatures_supports_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); +bool SiPrefix_eq(const enum LDKSiPrefix *NONNULL_PTR a, const enum LDKSiPrefix *NONNULL_PTR b); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Generates a non-cryptographic 64-bit hash of the SiPrefix. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +uint64_t SiPrefix_hash(const enum LDKSiPrefix *NONNULL_PTR o); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix. + * This is effectively 10^12 * the prefix multiplier */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES uint64_t SiPrefix_multiplier(const enum LDKSiPrefix *NONNULL_PTR this_arg); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Creates a copy of the Currency */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +enum LDKCurrency Currency_clone(const enum LDKCurrency *NONNULL_PTR orig); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Utility method to constructs a new Bitcoin-variant Currency */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +enum LDKCurrency Currency_bitcoin(void); /** - * Create a blank Features with no features set + * Utility method to constructs a new BitcoinTestnet-variant Currency */ -MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_empty(void); +enum LDKCurrency Currency_bitcoin_testnet(void); /** - * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order - * from most on-the-wire encodings. + * Utility method to constructs a new Regtest-variant Currency */ -MUST_USE_RES struct LDKu8slice InvoiceRequestFeatures_le_flags(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); +enum LDKCurrency Currency_regtest(void); /** - * Returns true if this `Features` has any optional flags set + * Utility method to constructs a new Simnet-variant Currency */ -MUST_USE_RES bool InvoiceRequestFeatures_supports_any_optional_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); +enum LDKCurrency Currency_simnet(void); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Utility method to constructs a new Signet-variant Currency */ -MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits_from(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, const struct LDKInvoiceRequestFeatures *NONNULL_PTR other); +enum LDKCurrency Currency_signet(void); /** - * Returns the set of required features unknown by `other`, as their bit position. + * Generates a non-cryptographic 64-bit hash of the Currency. */ -MUST_USE_RES struct LDKCVec_u64Z InvoiceRequestFeatures_required_unknown_bits_from(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, const struct LDKInvoiceRequestFeatures *NONNULL_PTR other); +uint64_t Currency_hash(const enum LDKCurrency *NONNULL_PTR o); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if two Currencys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); +bool Currency_eq(const enum LDKCurrency *NONNULL_PTR a, const enum LDKCurrency *NONNULL_PTR b); /** - * Returns true if this `Features` supports any bits which we do not know of + * Frees any resources used by the Sha256, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InvoiceRequestFeatures_supports_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); +void Sha256_free(struct LDKSha256 this_obj); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Creates a copy of the Sha256 */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKSha256 Sha256_clone(const struct LDKSha256 *NONNULL_PTR orig); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Generates a non-cryptographic 64-bit hash of the Sha256. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +uint64_t Sha256_hash(const struct LDKSha256 *NONNULL_PTR o); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Checks if two Sha256s contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool Sha256_eq(const struct LDKSha256 *NONNULL_PTR a, const struct LDKSha256 *NONNULL_PTR b); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Constructs a new [`Sha256`] from the given bytes, which are assumed to be the output of a + * single sha256 hash. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES struct LDKSha256 Sha256_from_bytes(const uint8_t (*bytes)[32]); /** - * Create a blank Features with no features set + * Frees any resources used by the Description, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_empty(void); +void Description_free(struct LDKDescription this_obj); /** - * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order - * from most on-the-wire encodings. + * Creates a copy of the Description */ -MUST_USE_RES struct LDKu8slice Bolt12InvoiceFeatures_le_flags(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKDescription Description_clone(const struct LDKDescription *NONNULL_PTR orig); /** - * Returns true if this `Features` has any optional flags set + * Generates a non-cryptographic 64-bit hash of the Description. */ -MUST_USE_RES bool Bolt12InvoiceFeatures_supports_any_optional_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +uint64_t Description_hash(const struct LDKDescription *NONNULL_PTR o); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Checks if two Descriptions contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR other); +bool Description_eq(const struct LDKDescription *NONNULL_PTR a, const struct LDKDescription *NONNULL_PTR b); /** - * Returns the set of required features unknown by `other`, as their bit position. + * Frees any resources used by the PayeePubKey, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCVec_u64Z Bolt12InvoiceFeatures_required_unknown_bits_from(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR other); +void PayeePubKey_free(struct LDKPayeePubKey this_obj); + +struct LDKPublicKey PayeePubKey_get_a(const struct LDKPayeePubKey *NONNULL_PTR this_ptr); + +void PayeePubKey_set_a(struct LDKPayeePubKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Constructs a new PayeePubKey given each field */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPayeePubKey PayeePubKey_new(struct LDKPublicKey a_arg); /** - * Returns true if this `Features` supports any bits which we do not know of + * Creates a copy of the PayeePubKey */ -MUST_USE_RES bool Bolt12InvoiceFeatures_supports_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKPayeePubKey PayeePubKey_clone(const struct LDKPayeePubKey *NONNULL_PTR orig); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Generates a non-cryptographic 64-bit hash of the PayeePubKey. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +uint64_t PayeePubKey_hash(const struct LDKPayeePubKey *NONNULL_PTR o); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Checks if two PayeePubKeys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool PayeePubKey_eq(const struct LDKPayeePubKey *NONNULL_PTR a, const struct LDKPayeePubKey *NONNULL_PTR b); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Frees any resources used by the ExpiryTime, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ExpiryTime_free(struct LDKExpiryTime this_obj); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Creates a copy of the ExpiryTime */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKExpiryTime ExpiryTime_clone(const struct LDKExpiryTime *NONNULL_PTR orig); /** - * Create a blank Features with no features set + * Generates a non-cryptographic 64-bit hash of the ExpiryTime. */ -MUST_USE_RES struct LDKBlindedHopFeatures BlindedHopFeatures_empty(void); +uint64_t ExpiryTime_hash(const struct LDKExpiryTime *NONNULL_PTR o); /** - * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order - * from most on-the-wire encodings. + * Checks if two ExpiryTimes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKu8slice BlindedHopFeatures_le_flags(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); +bool ExpiryTime_eq(const struct LDKExpiryTime *NONNULL_PTR a, const struct LDKExpiryTime *NONNULL_PTR b); /** - * Returns true if this `Features` has any optional flags set + * Frees any resources used by the MinFinalCltvExpiryDelta, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool BlindedHopFeatures_supports_any_optional_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); +void MinFinalCltvExpiryDelta_free(struct LDKMinFinalCltvExpiryDelta this_obj); + +uint64_t MinFinalCltvExpiryDelta_get_a(const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR this_ptr); + +void MinFinalCltvExpiryDelta_set_a(struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR this_ptr, uint64_t val); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Constructs a new MinFinalCltvExpiryDelta given each field */ -MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits_from(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, const struct LDKBlindedHopFeatures *NONNULL_PTR other); +MUST_USE_RES struct LDKMinFinalCltvExpiryDelta MinFinalCltvExpiryDelta_new(uint64_t a_arg); /** - * Returns the set of required features unknown by `other`, as their bit position. + * Creates a copy of the MinFinalCltvExpiryDelta */ -MUST_USE_RES struct LDKCVec_u64Z BlindedHopFeatures_required_unknown_bits_from(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, const struct LDKBlindedHopFeatures *NONNULL_PTR other); +struct LDKMinFinalCltvExpiryDelta MinFinalCltvExpiryDelta_clone(const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR orig); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Generates a non-cryptographic 64-bit hash of the MinFinalCltvExpiryDelta. */ -MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); +uint64_t MinFinalCltvExpiryDelta_hash(const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR o); /** - * Returns true if this `Features` supports any bits which we do not know of + * Checks if two MinFinalCltvExpiryDeltas contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool BlindedHopFeatures_supports_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); +bool MinFinalCltvExpiryDelta_eq(const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR a, const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR b); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Frees any resources used by the Fallback */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void Fallback_free(struct LDKFallback this_ptr); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Creates a copy of the Fallback */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKFallback Fallback_clone(const struct LDKFallback *NONNULL_PTR orig); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Utility method to constructs a new SegWitProgram-variant Fallback */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKFallback Fallback_seg_wit_program(struct LDKWitnessVersion version, struct LDKCVec_u8Z program); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Utility method to constructs a new PubKeyHash-variant Fallback */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKFallback Fallback_pub_key_hash(struct LDKTwentyBytes a); /** - * Create a blank Features with no features set + * Utility method to constructs a new ScriptHash-variant Fallback */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); +struct LDKFallback Fallback_script_hash(struct LDKTwentyBytes a); /** - * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order - * from most on-the-wire encodings. + * Generates a non-cryptographic 64-bit hash of the Fallback. */ -MUST_USE_RES struct LDKu8slice ChannelTypeFeatures_le_flags(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +uint64_t Fallback_hash(const struct LDKFallback *NONNULL_PTR o); /** - * Returns true if this `Features` has any optional flags set + * Checks if two Fallbacks contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_any_optional_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +bool Fallback_eq(const struct LDKFallback *NONNULL_PTR a, const struct LDKFallback *NONNULL_PTR b); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Frees any resources used by the Bolt11InvoiceSignature, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits_from(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, const struct LDKChannelTypeFeatures *NONNULL_PTR other); +void Bolt11InvoiceSignature_free(struct LDKBolt11InvoiceSignature this_obj); + +struct LDKRecoverableSignature Bolt11InvoiceSignature_get_a(const struct LDKBolt11InvoiceSignature *NONNULL_PTR this_ptr); + +void Bolt11InvoiceSignature_set_a(struct LDKBolt11InvoiceSignature *NONNULL_PTR this_ptr, struct LDKRecoverableSignature val); /** - * Returns the set of required features unknown by `other`, as their bit position. + * Constructs a new Bolt11InvoiceSignature given each field */ -MUST_USE_RES struct LDKCVec_u64Z ChannelTypeFeatures_required_unknown_bits_from(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, const struct LDKChannelTypeFeatures *NONNULL_PTR other); +MUST_USE_RES struct LDKBolt11InvoiceSignature Bolt11InvoiceSignature_new(struct LDKRecoverableSignature a_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Creates a copy of the Bolt11InvoiceSignature */ -MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKBolt11InvoiceSignature Bolt11InvoiceSignature_clone(const struct LDKBolt11InvoiceSignature *NONNULL_PTR orig); /** - * Returns true if this `Features` supports any bits which we do not know of + * Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceSignature. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +uint64_t Bolt11InvoiceSignature_hash(const struct LDKBolt11InvoiceSignature *NONNULL_PTR o); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Checks if two Bolt11InvoiceSignatures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool Bolt11InvoiceSignature_eq(const struct LDKBolt11InvoiceSignature *NONNULL_PTR a, const struct LDKBolt11InvoiceSignature *NONNULL_PTR b); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Frees any resources used by the PrivateRoute, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void PrivateRoute_free(struct LDKPrivateRoute this_obj); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Creates a copy of the PrivateRoute */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKPrivateRoute PrivateRoute_clone(const struct LDKPrivateRoute *NONNULL_PTR orig); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Generates a non-cryptographic 64-bit hash of the PrivateRoute. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +uint64_t PrivateRoute_hash(const struct LDKPrivateRoute *NONNULL_PTR o); /** - * Unsets the `upfront_shutdown_script` feature + * Checks if two PrivateRoutes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_upfront_shutdown_script(struct LDKInitFeatures this_arg); +bool PrivateRoute_eq(const struct LDKPrivateRoute *NONNULL_PTR a, const struct LDKPrivateRoute *NONNULL_PTR b); /** - * Unsets the `upfront_shutdown_script` feature + * Disassembles the `SignedRawBolt11Invoice` into its three parts: + * 1. raw invoice + * 2. hash of the raw invoice + * 3. signature */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_upfront_shutdown_script(struct LDKNodeFeatures this_arg); +MUST_USE_RES struct LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ SignedRawBolt11Invoice_into_parts(struct LDKSignedRawBolt11Invoice this_arg); /** - * Unsets the `shutdown_anysegwit` feature + * The [`RawBolt11Invoice`] which was signed. */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_shutdown_anysegwit(struct LDKInitFeatures this_arg); +MUST_USE_RES struct LDKRawBolt11Invoice SignedRawBolt11Invoice_raw_invoice(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Unsets the `shutdown_anysegwit` feature + * The hash of the [`RawBolt11Invoice`] that was signed. */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_shutdown_anysegwit(struct LDKNodeFeatures this_arg); +MUST_USE_RES const uint8_t (*SignedRawBolt11Invoice_signable_hash(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg))[32]; /** - * Unsets the `wumbo` feature + * Signature for the invoice. */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_wumbo(struct LDKInitFeatures this_arg); +MUST_USE_RES struct LDKBolt11InvoiceSignature SignedRawBolt11Invoice_signature(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Unsets the `wumbo` feature + * Recovers the public key used for signing the invoice from the recoverable signature. */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_wumbo(struct LDKNodeFeatures this_arg); +MUST_USE_RES struct LDKCResult_PayeePubKeySecp256k1ErrorZ SignedRawBolt11Invoice_recover_payee_pub_key(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Unsets the `scid_privacy` feature + * Checks if the signature is valid for the included payee public key or if none exists if it's + * valid for the recovered signature (which should always be true?). */ -void InitFeatures_clear_scid_privacy(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool SignedRawBolt11Invoice_check_signature(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Unsets the `scid_privacy` feature + * Calculate the hash of the encoded `RawBolt11Invoice` which should be signed. */ -void NodeFeatures_clear_scid_privacy(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes RawBolt11Invoice_signable_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Unsets the `scid_privacy` feature + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelTypeFeatures_clear_scid_privacy(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKSha256 RawBolt11Invoice_payment_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Unsets the `anchors_zero_fee_htlc_tx` feature + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void InitFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKDescription RawBolt11Invoice_description(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Unsets the `anchors_zero_fee_htlc_tx` feature + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void NodeFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPayeePubKey RawBolt11Invoice_payee_pub_key(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Unsets the `anchors_zero_fee_htlc_tx` feature + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelTypeFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKSha256 RawBolt11Invoice_description_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Unsets the `route_blinding` feature + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void InitFeatures_clear_route_blinding(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKExpiryTime RawBolt11Invoice_expiry_time(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Unsets the `route_blinding` feature + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void NodeFeatures_clear_route_blinding(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKMinFinalCltvExpiryDelta RawBolt11Invoice_min_final_cltv_expiry_delta(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKCOption_ThirtyTwoBytesZ RawBolt11Invoice_payment_secret(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKCOption_CVec_u8ZZ RawBolt11Invoice_payment_metadata(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void InitFeatures_set_data_loss_protect_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt11InvoiceFeatures RawBolt11Invoice_features(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKCVec_PrivateRouteZ RawBolt11Invoice_private_routes(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Returns `None` if no amount is set or on overflow. */ -void InitFeatures_set_data_loss_protect_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z RawBolt11Invoice_amount_pico_btc(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); + +MUST_USE_RES enum LDKCurrency RawBolt11Invoice_currency(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`. + * + * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. */ -MUST_USE_RES bool InitFeatures_supports_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_unix_timestamp(uint64_t unix_seconds); /** - * Set this feature as optional. + * Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in + * the range `0..=MAX_TIMESTAMP`. + * + * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices. + * + * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. */ -void NodeFeatures_set_data_loss_protect_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_system_time(uint64_t time); /** - * Set this feature as required. + * Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range + * `0..=MAX_TIMESTAMP`. + * + * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices. + * + * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. */ -void NodeFeatures_set_data_loss_protect_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_duration_since_epoch(uint64_t duration); /** - * Checks if this feature is supported. + * Returns the Unix timestamp representing the stored time */ -MUST_USE_RES bool NodeFeatures_supports_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t PositiveTimestamp_as_unix_timestamp(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Returns the duration of the stored time since the Unix epoch */ -MUST_USE_RES bool InitFeatures_requires_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t PositiveTimestamp_as_duration_since_epoch(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Returns the [`SystemTime`] representing the stored time */ -MUST_USE_RES bool NodeFeatures_requires_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t PositiveTimestamp_as_time(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * The hash of the [`RawBolt11Invoice`] that was signed. */ -void InitFeatures_set_initial_routing_sync_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes Bolt11Invoice_signable_hash(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Transform the `Bolt11Invoice` into its unchecked version. */ -void InitFeatures_set_initial_routing_sync_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKSignedRawBolt11Invoice Bolt11Invoice_into_signed_raw(struct LDKBolt11Invoice this_arg); /** - * Checks if this feature is supported. + * Check that the invoice is signed correctly and that key recovery works */ -MUST_USE_RES bool InitFeatures_initial_routing_sync(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneBolt11SemanticErrorZ Bolt11Invoice_check_signature(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Constructs a `Bolt11Invoice` from a [`SignedRawBolt11Invoice`] by checking all its invariants. + * ``` + * use lightning_invoice::*; + * + * let invoice = \"lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\\ + * h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\\ + * 5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\\ + * h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\\ + * j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\\ + * ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\\ + * guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\\ + * ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\\ + * p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\\ + * 8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\\ + * j5r6drg6k6zcqj0fcwg\"; + * + * let signed = invoice.parse::().unwrap(); + * + * assert!(Bolt11Invoice::from_signed(signed).is_ok()); + * ``` */ -void InitFeatures_set_upfront_shutdown_script_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ Bolt11Invoice_from_signed(struct LDKSignedRawBolt11Invoice signed_invoice); /** - * Set this feature as required. + * Returns the `Bolt11Invoice`'s timestamp (should equal its creation time) */ -void InitFeatures_set_upfront_shutdown_script_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt11Invoice_timestamp(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Returns the `Bolt11Invoice`'s timestamp as a duration since the Unix epoch */ -MUST_USE_RES bool InitFeatures_supports_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt11Invoice_duration_since_epoch(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Returns the hash to which we will receive the preimage on completion of the payment */ -void NodeFeatures_set_upfront_shutdown_script_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES const uint8_t (*Bolt11Invoice_payment_hash(const struct LDKBolt11Invoice *NONNULL_PTR this_arg))[32]; /** - * Set this feature as required. + * Get the payee's public key if one was included in the invoice + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void NodeFeatures_set_upfront_shutdown_script_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Bolt11Invoice_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Get the payment secret if one was included in the invoice */ -MUST_USE_RES bool NodeFeatures_supports_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES const uint8_t (*Bolt11Invoice_payment_secret(const struct LDKBolt11Invoice *NONNULL_PTR this_arg))[32]; /** - * Checks if this feature is required. + * Get the payment metadata blob if one was included in the invoice */ -MUST_USE_RES bool InitFeatures_requires_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ Bolt11Invoice_payment_metadata(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Get the invoice features if they were included in the invoice + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool NodeFeatures_requires_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11Invoice_features(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Recover the payee's public key (only to be used if none was included in the invoice) */ -void InitFeatures_set_gossip_queries_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Bolt11Invoice_recover_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Recover the payee's public key if one was included in the invoice, otherwise return the + * recovered public key from the signature */ -void InitFeatures_set_gossip_queries_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Bolt11Invoice_get_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Returns the Duration since the Unix epoch at which the invoice expires. + * Returning None if overflow occurred. */ -MUST_USE_RES bool InitFeatures_supports_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z Bolt11Invoice_expires_at(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`]. */ -void NodeFeatures_set_gossip_queries_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt11Invoice_expiry_time(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Returns whether the invoice has expired. */ -void NodeFeatures_set_gossip_queries_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Bolt11Invoice_is_expired(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Returns the Duration remaining until the invoice expires. */ -MUST_USE_RES bool NodeFeatures_supports_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt11Invoice_duration_until_expiry(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Returns the Duration remaining until the invoice expires given the current time. + * `time` is the timestamp as a duration since the Unix epoch. */ -MUST_USE_RES bool InitFeatures_requires_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt11Invoice_expiration_remaining_from_epoch(const struct LDKBolt11Invoice *NONNULL_PTR this_arg, uint64_t time); /** - * Checks if this feature is required. + * Returns whether the expiry time would pass at the given point in time. + * `at_time` is the timestamp as a duration since the Unix epoch. */ -MUST_USE_RES bool NodeFeatures_requires_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Bolt11Invoice_would_expire(const struct LDKBolt11Invoice *NONNULL_PTR this_arg, uint64_t at_time); /** - * Set this feature as optional. + * Returns the invoice's `min_final_cltv_expiry_delta` time, if present, otherwise + * [`DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA`]. */ -void InitFeatures_set_variable_length_onion_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt11Invoice_min_final_cltv_expiry_delta(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Returns a list of all fallback addresses as [`Address`]es */ -void InitFeatures_set_variable_length_onion_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_AddressZ Bolt11Invoice_fallback_addresses(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Returns a list of all routes included in the invoice */ -MUST_USE_RES bool InitFeatures_supports_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_PrivateRouteZ Bolt11Invoice_private_routes(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Returns a list of all routes included in the invoice as the underlying hints */ -void NodeFeatures_set_variable_length_onion_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_RouteHintZ Bolt11Invoice_route_hints(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Returns the currency for which the invoice was issued */ -void NodeFeatures_set_variable_length_onion_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES enum LDKCurrency Bolt11Invoice_currency(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Returns the amount if specified in the invoice as millisatoshis. */ -MUST_USE_RES bool NodeFeatures_supports_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z Bolt11Invoice_amount_milli_satoshis(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Creates a new `Description` if `description` is at most 1023 * 5 bits (i.e., 639 bytes) + * long, and returns [`CreationError::DescriptionTooLong`] otherwise. + * + * Please note that single characters may use more than one byte due to UTF8 encoding. */ -void Bolt11InvoiceFeatures_set_variable_length_onion_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_DescriptionCreationErrorZ Description_new(struct LDKStr description); /** - * Set this feature as required. + * Creates an empty `Description`. */ -void Bolt11InvoiceFeatures_set_variable_length_onion_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKDescription Description_empty(void); /** - * Checks if this feature is supported. + * Returns the underlying description [`UntrustedString`] */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKUntrustedString Description_into_inner(struct LDKDescription this_arg); /** - * Checks if this feature is required. + * Get a reference to the underlying description [`UntrustedString`] */ -MUST_USE_RES bool InitFeatures_requires_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKUntrustedString Description_as_inner(const struct LDKDescription *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Get the string representation of a Description object */ -MUST_USE_RES bool NodeFeatures_requires_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKStr Description_to_str(const struct LDKDescription *NONNULL_PTR o); /** - * Checks if this feature is required. + * Construct an `ExpiryTime` from seconds. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKExpiryTime ExpiryTime_from_seconds(uint64_t seconds); /** - * Set this feature as optional. + * Construct an `ExpiryTime` from a [`Duration`], dropping the sub-second part. */ -void InitFeatures_set_static_remote_key_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKExpiryTime ExpiryTime_from_duration(uint64_t duration); /** - * Set this feature as required. + * Returns the expiry time in seconds */ -void InitFeatures_set_static_remote_key_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t ExpiryTime_as_seconds(const struct LDKExpiryTime *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Returns a reference to the underlying [`Duration`] (=expiry time) */ -MUST_USE_RES bool InitFeatures_supports_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t ExpiryTime_as_duration(const struct LDKExpiryTime *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Creates a new (partial) route from a list of hops */ -void NodeFeatures_set_static_remote_key_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_PrivateRouteCreationErrorZ PrivateRoute_new(struct LDKRouteHint hops); /** - * Set this feature as required. + * Returns the underlying list of hops */ -void NodeFeatures_set_static_remote_key_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRouteHint PrivateRoute_into_inner(struct LDKPrivateRoute this_arg); /** - * Checks if this feature is supported. + * Creates a copy of the CreationError */ -MUST_USE_RES bool NodeFeatures_supports_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKCreationError CreationError_clone(const enum LDKCreationError *NONNULL_PTR orig); /** - * Set this feature as optional. + * Utility method to constructs a new DescriptionTooLong-variant CreationError */ -void ChannelTypeFeatures_set_static_remote_key_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +enum LDKCreationError CreationError_description_too_long(void); /** - * Set this feature as required. + * Utility method to constructs a new RouteTooLong-variant CreationError */ -void ChannelTypeFeatures_set_static_remote_key_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +enum LDKCreationError CreationError_route_too_long(void); /** - * Checks if this feature is supported. + * Utility method to constructs a new TimestampOutOfBounds-variant CreationError */ -MUST_USE_RES bool ChannelTypeFeatures_supports_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +enum LDKCreationError CreationError_timestamp_out_of_bounds(void); /** - * Checks if this feature is required. + * Utility method to constructs a new InvalidAmount-variant CreationError */ -MUST_USE_RES bool InitFeatures_requires_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKCreationError CreationError_invalid_amount(void); /** - * Checks if this feature is required. + * Utility method to constructs a new MissingRouteHints-variant CreationError */ -MUST_USE_RES bool NodeFeatures_requires_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKCreationError CreationError_missing_route_hints(void); /** - * Checks if this feature is required. + * Utility method to constructs a new MinFinalCltvExpiryDeltaTooShort-variant CreationError */ -MUST_USE_RES bool ChannelTypeFeatures_requires_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +enum LDKCreationError CreationError_min_final_cltv_expiry_delta_too_short(void); /** - * Set this feature as optional. + * Checks if two CreationErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void InitFeatures_set_payment_secret_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +bool CreationError_eq(const enum LDKCreationError *NONNULL_PTR a, const enum LDKCreationError *NONNULL_PTR b); /** - * Set this feature as required. + * Get the string representation of a CreationError object */ -void InitFeatures_set_payment_secret_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKStr CreationError_to_str(const enum LDKCreationError *NONNULL_PTR o); /** - * Checks if this feature is supported. + * Creates a copy of the Bolt11SemanticError */ -MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt11SemanticError Bolt11SemanticError_clone(const enum LDKBolt11SemanticError *NONNULL_PTR orig); /** - * Set this feature as optional. + * Utility method to constructs a new NoPaymentHash-variant Bolt11SemanticError */ -void NodeFeatures_set_payment_secret_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt11SemanticError Bolt11SemanticError_no_payment_hash(void); /** - * Set this feature as required. + * Utility method to constructs a new MultiplePaymentHashes-variant Bolt11SemanticError */ -void NodeFeatures_set_payment_secret_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt11SemanticError Bolt11SemanticError_multiple_payment_hashes(void); /** - * Checks if this feature is supported. + * Utility method to constructs a new NoDescription-variant Bolt11SemanticError */ -MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt11SemanticError Bolt11SemanticError_no_description(void); /** - * Set this feature as optional. + * Utility method to constructs a new MultipleDescriptions-variant Bolt11SemanticError */ -void Bolt11InvoiceFeatures_set_payment_secret_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +enum LDKBolt11SemanticError Bolt11SemanticError_multiple_descriptions(void); /** - * Set this feature as required. + * Utility method to constructs a new NoPaymentSecret-variant Bolt11SemanticError */ -void Bolt11InvoiceFeatures_set_payment_secret_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +enum LDKBolt11SemanticError Bolt11SemanticError_no_payment_secret(void); /** - * Checks if this feature is supported. + * Utility method to constructs a new MultiplePaymentSecrets-variant Bolt11SemanticError */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +enum LDKBolt11SemanticError Bolt11SemanticError_multiple_payment_secrets(void); /** - * Checks if this feature is required. + * Utility method to constructs a new InvalidFeatures-variant Bolt11SemanticError */ -MUST_USE_RES bool InitFeatures_requires_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt11SemanticError Bolt11SemanticError_invalid_features(void); /** - * Checks if this feature is required. + * Utility method to constructs a new InvalidRecoveryId-variant Bolt11SemanticError */ -MUST_USE_RES bool NodeFeatures_requires_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt11SemanticError Bolt11SemanticError_invalid_recovery_id(void); /** - * Checks if this feature is required. + * Utility method to constructs a new InvalidSignature-variant Bolt11SemanticError */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +enum LDKBolt11SemanticError Bolt11SemanticError_invalid_signature(void); /** - * Set this feature as optional. + * Utility method to constructs a new ImpreciseAmount-variant Bolt11SemanticError */ -void InitFeatures_set_basic_mpp_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt11SemanticError Bolt11SemanticError_imprecise_amount(void); /** - * Set this feature as required. + * Checks if two Bolt11SemanticErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void InitFeatures_set_basic_mpp_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +bool Bolt11SemanticError_eq(const enum LDKBolt11SemanticError *NONNULL_PTR a, const enum LDKBolt11SemanticError *NONNULL_PTR b); /** - * Checks if this feature is supported. + * Get the string representation of a Bolt11SemanticError object */ -MUST_USE_RES bool InitFeatures_supports_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKStr Bolt11SemanticError_to_str(const enum LDKBolt11SemanticError *NONNULL_PTR o); /** - * Set this feature as optional. + * Frees any resources used by the SignOrCreationError */ -void NodeFeatures_set_basic_mpp_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void SignOrCreationError_free(struct LDKSignOrCreationError this_ptr); /** - * Set this feature as required. + * Creates a copy of the SignOrCreationError */ -void NodeFeatures_set_basic_mpp_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKSignOrCreationError SignOrCreationError_clone(const struct LDKSignOrCreationError *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Utility method to constructs a new SignError-variant SignOrCreationError */ -MUST_USE_RES bool NodeFeatures_supports_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKSignOrCreationError SignOrCreationError_sign_error(void); /** - * Set this feature as optional. + * Utility method to constructs a new CreationError-variant SignOrCreationError */ -void Bolt11InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKSignOrCreationError SignOrCreationError_creation_error(enum LDKCreationError a); /** - * Set this feature as required. + * Checks if two SignOrCreationErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void Bolt11InvoiceFeatures_set_basic_mpp_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +bool SignOrCreationError_eq(const struct LDKSignOrCreationError *NONNULL_PTR a, const struct LDKSignOrCreationError *NONNULL_PTR b); /** - * Checks if this feature is supported. + * Get the string representation of a SignOrCreationError object */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKStr SignOrCreationError_to_str(const struct LDKSignOrCreationError *NONNULL_PTR o); /** - * Set this feature as optional. + * Read a SiPrefix object from a string */ -void Bolt12InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKCResult_SiPrefixBolt11ParseErrorZ SiPrefix_from_str(struct LDKStr s); /** - * Set this feature as required. + * Read a Bolt11Invoice object from a string */ -void Bolt12InvoiceFeatures_set_basic_mpp_required(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ Bolt11Invoice_from_str(struct LDKStr s); /** - * Checks if this feature is supported. + * Read a SignedRawBolt11Invoice object from a string */ -MUST_USE_RES bool Bolt12InvoiceFeatures_supports_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ SignedRawBolt11Invoice_from_str(struct LDKStr s); /** - * Checks if this feature is required. + * Get the string representation of a Bolt11ParseError object */ -MUST_USE_RES bool InitFeatures_requires_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKStr Bolt11ParseError_to_str(const struct LDKBolt11ParseError *NONNULL_PTR o); /** - * Checks if this feature is required. + * Get the string representation of a ParseOrSemanticError object */ -MUST_USE_RES bool NodeFeatures_requires_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKStr ParseOrSemanticError_to_str(const struct LDKParseOrSemanticError *NONNULL_PTR o); /** - * Checks if this feature is required. + * Get the string representation of a Bolt11Invoice object */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKStr Bolt11Invoice_to_str(const struct LDKBolt11Invoice *NONNULL_PTR o); /** - * Checks if this feature is required. + * Get the string representation of a SignedRawBolt11Invoice object */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKStr SignedRawBolt11Invoice_to_str(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR o); /** - * Set this feature as optional. + * Get the string representation of a Currency object */ -void InitFeatures_set_wumbo_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKStr Currency_to_str(const enum LDKCurrency *NONNULL_PTR o); /** - * Set this feature as required. + * Get the string representation of a SiPrefix object */ -void InitFeatures_set_wumbo_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKStr SiPrefix_to_str(const enum LDKSiPrefix *NONNULL_PTR o); /** - * Checks if this feature is supported. + * Frees any resources used by the GraphSyncError */ -MUST_USE_RES bool InitFeatures_supports_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void GraphSyncError_free(struct LDKGraphSyncError this_ptr); /** - * Set this feature as optional. + * Creates a copy of the GraphSyncError */ -void NodeFeatures_set_wumbo_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKGraphSyncError GraphSyncError_clone(const struct LDKGraphSyncError *NONNULL_PTR orig); /** - * Set this feature as required. + * Utility method to constructs a new DecodeError-variant GraphSyncError */ -void NodeFeatures_set_wumbo_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKGraphSyncError GraphSyncError_decode_error(struct LDKDecodeError a); /** - * Checks if this feature is supported. + * Utility method to constructs a new LightningError-variant GraphSyncError */ -MUST_USE_RES bool NodeFeatures_supports_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKGraphSyncError GraphSyncError_lightning_error(struct LDKLightningError a); /** - * Checks if this feature is required. + * Frees any resources used by the RapidGossipSync, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_requires_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void RapidGossipSync_free(struct LDKRapidGossipSync this_obj); /** - * Checks if this feature is required. + * Instantiate a new [`RapidGossipSync`] instance. */ -MUST_USE_RES bool NodeFeatures_requires_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRapidGossipSync RapidGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); /** - * Set this feature as optional. + * Sync gossip data from a file. + * Returns the last sync timestamp to be used the next time rapid sync data is queried. + * + * `network_graph`: The network graph to apply the updates to + * + * `sync_path`: Path to the file where the gossip update data is located + * */ -void InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_sync_network_graph_with_file_path(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKStr sync_path); /** - * Set this feature as required. + * Update network graph from binary data. + * Returns the last sync timestamp to be used the next time rapid sync data is queried. + * + * `update_data`: `&[u8]` binary stream that comprises the update data */ -void InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data); /** - * Checks if this feature is supported. + * Update network graph from binary data. + * Returns the last sync timestamp to be used the next time rapid sync data is queried. + * + * `update_data`: `&[u8]` binary stream that comprises the update data + * `current_time_unix`: `Option` optional current timestamp to verify data age */ -MUST_USE_RES bool InitFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph_no_std(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data, struct LDKCOption_u64Z current_time_unix); /** - * Set this feature as optional. + * Returns whether a rapid gossip sync has completed at least once. */ -void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool RapidGossipSync_is_initial_sync_complete(const struct LDKRapidGossipSync *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Frees any resources used by the LiquidityEvent */ -void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LiquidityEvent_free(struct LDKLiquidityEvent this_ptr); /** - * Checks if this feature is supported. + * Creates a copy of the LiquidityEvent */ -MUST_USE_RES bool NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKLiquidityEvent LiquidityEvent_clone(const struct LDKLiquidityEvent *NONNULL_PTR orig); /** - * Set this feature as optional. + * Utility method to constructs a new LSPS0Client-variant LiquidityEvent */ -void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKLiquidityEvent LiquidityEvent_lsps0_client(struct LDKLSPS0ClientEvent a); /** - * Set this feature as required. + * Utility method to constructs a new LSPS1Client-variant LiquidityEvent */ -void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKLiquidityEvent LiquidityEvent_lsps1_client(struct LDKLSPS1ClientEvent a); /** - * Checks if this feature is supported. + * Utility method to constructs a new LSPS2Client-variant LiquidityEvent */ -MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKLiquidityEvent LiquidityEvent_lsps2_client(struct LDKLSPS2ClientEvent a); /** - * Checks if this feature is required. + * Utility method to constructs a new LSPS2Service-variant LiquidityEvent */ -MUST_USE_RES bool InitFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLiquidityEvent LiquidityEvent_lsps2_service(struct LDKLSPS2ServiceEvent a); /** - * Checks if this feature is required. + * Checks if two LiquidityEvents contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES bool NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +bool LiquidityEvent_eq(const struct LDKLiquidityEvent *NONNULL_PTR a, const struct LDKLiquidityEvent *NONNULL_PTR b); /** - * Checks if this feature is required. + * Frees any resources used by the LSPS0ClientHandler, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void LSPS0ClientHandler_free(struct LDKLSPS0ClientHandler this_obj); /** - * Set this feature as optional. + * Calls bLIP-50 / LSPS0's `list_protocols`. + * + * Please refer to the [bLIP-50 / LSPS0 + * specifcation](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) + * for more information. */ -void InitFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void LSPS0ClientHandler_list_protocols(const struct LDKLSPS0ClientHandler *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id); /** - * Set this feature as required. + * Frees any resources used by the LSPS0ClientEvent */ -void InitFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void LSPS0ClientEvent_free(struct LDKLSPS0ClientEvent this_ptr); /** - * Checks if this feature is supported. + * Creates a copy of the LSPS0ClientEvent */ -MUST_USE_RES bool InitFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0ClientEvent LSPS0ClientEvent_clone(const struct LDKLSPS0ClientEvent *NONNULL_PTR orig); /** - * Set this feature as optional. + * Utility method to constructs a new ListProtocolsResponse-variant LSPS0ClientEvent */ -void NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0ClientEvent LSPS0ClientEvent_list_protocols_response(struct LDKPublicKey counterparty_node_id, struct LDKCVec_u16Z protocols); /** - * Set this feature as required. + * Checks if two LSPS0ClientEvents contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void NodeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +bool LSPS0ClientEvent_eq(const struct LDKLSPS0ClientEvent *NONNULL_PTR a, const struct LDKLSPS0ClientEvent *NONNULL_PTR b); /** - * Checks if this feature is supported. + * Frees any resources used by the LSPS0ListProtocolsRequest, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool NodeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS0ListProtocolsRequest_free(struct LDKLSPS0ListProtocolsRequest this_obj); /** - * Set this feature as optional. + * Constructs a new LSPS0ListProtocolsRequest given each field */ -void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPS0ListProtocolsRequest LSPS0ListProtocolsRequest_new(void); /** - * Set this feature as required. + * Creates a copy of the LSPS0ListProtocolsRequest */ -void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0ListProtocolsRequest LSPS0ListProtocolsRequest_clone(const struct LDKLSPS0ListProtocolsRequest *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Checks if two LSPS0ListProtocolsRequests contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +bool LSPS0ListProtocolsRequest_eq(const struct LDKLSPS0ListProtocolsRequest *NONNULL_PTR a, const struct LDKLSPS0ListProtocolsRequest *NONNULL_PTR b); /** - * Checks if this feature is required. + * Frees any resources used by the LSPS0ListProtocolsResponse, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void LSPS0ListProtocolsResponse_free(struct LDKLSPS0ListProtocolsResponse this_obj); /** - * Checks if this feature is required. + * A list of supported protocols. + * + * Returns a copy of the field. */ -MUST_USE_RES bool NodeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u16Z LSPS0ListProtocolsResponse_get_protocols(const struct LDKLSPS0ListProtocolsResponse *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * A list of supported protocols. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void LSPS0ListProtocolsResponse_set_protocols(struct LDKLSPS0ListProtocolsResponse *NONNULL_PTR this_ptr, struct LDKCVec_u16Z val); /** - * Set this feature as optional. + * Constructs a new LSPS0ListProtocolsResponse given each field */ -void InitFeatures_set_route_blinding_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPS0ListProtocolsResponse LSPS0ListProtocolsResponse_new(struct LDKCVec_u16Z protocols_arg); /** - * Set this feature as required. + * Creates a copy of the LSPS0ListProtocolsResponse */ -void InitFeatures_set_route_blinding_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0ListProtocolsResponse LSPS0ListProtocolsResponse_clone(const struct LDKLSPS0ListProtocolsResponse *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Checks if two LSPS0ListProtocolsResponses contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool InitFeatures_supports_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); +bool LSPS0ListProtocolsResponse_eq(const struct LDKLSPS0ListProtocolsResponse *NONNULL_PTR a, const struct LDKLSPS0ListProtocolsResponse *NONNULL_PTR b); /** - * Set this feature as optional. + * Frees any resources used by the LSPS0Request */ -void NodeFeatures_set_route_blinding_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS0Request_free(struct LDKLSPS0Request this_ptr); /** - * Set this feature as required. + * Creates a copy of the LSPS0Request */ -void NodeFeatures_set_route_blinding_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0Request LSPS0Request_clone(const struct LDKLSPS0Request *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Utility method to constructs a new ListProtocols-variant LSPS0Request */ -MUST_USE_RES bool NodeFeatures_supports_route_blinding(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0Request LSPS0Request_list_protocols(struct LDKLSPS0ListProtocolsRequest a); /** - * Checks if this feature is required. + * Checks if two LSPS0Requests contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES bool InitFeatures_requires_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); +bool LSPS0Request_eq(const struct LDKLSPS0Request *NONNULL_PTR a, const struct LDKLSPS0Request *NONNULL_PTR b); /** - * Checks if this feature is required. + * Returns the method name associated with the given request variant. */ -MUST_USE_RES bool NodeFeatures_requires_route_blinding(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKStr LSPS0Request_method(const struct LDKLSPS0Request *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Frees any resources used by the LSPS0Response */ -void InitFeatures_set_shutdown_any_segwit_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void LSPS0Response_free(struct LDKLSPS0Response this_ptr); /** - * Set this feature as required. + * Creates a copy of the LSPS0Response */ -void InitFeatures_set_shutdown_any_segwit_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0Response LSPS0Response_clone(const struct LDKLSPS0Response *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Utility method to constructs a new ListProtocols-variant LSPS0Response */ -MUST_USE_RES bool InitFeatures_supports_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0Response LSPS0Response_list_protocols(struct LDKLSPS0ListProtocolsResponse a); /** - * Set this feature as optional. + * Utility method to constructs a new ListProtocolsError-variant LSPS0Response */ -void NodeFeatures_set_shutdown_any_segwit_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0Response LSPS0Response_list_protocols_error(struct LDKLSPSResponseError a); /** - * Set this feature as required. + * Checks if two LSPS0Responses contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void NodeFeatures_set_shutdown_any_segwit_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +bool LSPS0Response_eq(const struct LDKLSPS0Response *NONNULL_PTR a, const struct LDKLSPS0Response *NONNULL_PTR b); /** - * Checks if this feature is supported. + * Frees any resources used by the LSPS0Message */ -MUST_USE_RES bool NodeFeatures_supports_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS0Message_free(struct LDKLSPS0Message this_ptr); /** - * Checks if this feature is required. + * Creates a copy of the LSPS0Message */ -MUST_USE_RES bool InitFeatures_requires_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0Message LSPS0Message_clone(const struct LDKLSPS0Message *NONNULL_PTR orig); /** - * Checks if this feature is required. + * Utility method to constructs a new Request-variant LSPS0Message */ -MUST_USE_RES bool NodeFeatures_requires_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0Message LSPS0Message_request(struct LDKLSPSRequestId a, struct LDKLSPS0Request b); /** - * Set this feature as optional. + * Utility method to constructs a new Response-variant LSPS0Message */ -void InitFeatures_set_dual_fund_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPS0Message LSPS0Message_response(struct LDKLSPSRequestId a, struct LDKLSPS0Response b); /** - * Set this feature as required. + * Checks if two LSPS0Messages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void InitFeatures_set_dual_fund_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +bool LSPS0Message_eq(const struct LDKLSPS0Message *NONNULL_PTR a, const struct LDKLSPS0Message *NONNULL_PTR b); /** - * Checks if this feature is supported. + * Frees any resources used by the RawLSPSMessage, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_supports_dual_fund(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void RawLSPSMessage_free(struct LDKRawLSPSMessage this_obj); /** - * Set this feature as optional. + * The raw string payload that holds the actual message. */ -void NodeFeatures_set_dual_fund_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKStr RawLSPSMessage_get_payload(const struct LDKRawLSPSMessage *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The raw string payload that holds the actual message. */ -void NodeFeatures_set_dual_fund_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void RawLSPSMessage_set_payload(struct LDKRawLSPSMessage *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Checks if this feature is supported. + * Constructs a new RawLSPSMessage given each field */ -MUST_USE_RES bool NodeFeatures_supports_dual_fund(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRawLSPSMessage RawLSPSMessage_new(struct LDKStr payload_arg); /** - * Checks if this feature is required. + * Creates a copy of the RawLSPSMessage */ -MUST_USE_RES bool InitFeatures_requires_dual_fund(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKRawLSPSMessage RawLSPSMessage_clone(const struct LDKRawLSPSMessage *NONNULL_PTR orig); /** - * Checks if this feature is required. + * Checks if two RawLSPSMessages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool NodeFeatures_requires_dual_fund(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +bool RawLSPSMessage_eq(const struct LDKRawLSPSMessage *NONNULL_PTR a, const struct LDKRawLSPSMessage *NONNULL_PTR b); /** - * Set this feature as optional. + * Serialize the RawLSPSMessage object into a byte array which can be read by RawLSPSMessage_read */ -void InitFeatures_set_taproot_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z RawLSPSMessage_write(const struct LDKRawLSPSMessage *NONNULL_PTR obj); /** - * Set this feature as required. + * Read a RawLSPSMessage from a byte array, created by RawLSPSMessage_write */ -void InitFeatures_set_taproot_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCResult_RawLSPSMessageDecodeErrorZ RawLSPSMessage_read(struct LDKu8slice ser); /** - * Checks if this feature is supported. + * Constructs a new Type which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Type must be freed before this_arg is */ -MUST_USE_RES bool InitFeatures_supports_taproot(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKType RawLSPSMessage_as_Type(const struct LDKRawLSPSMessage *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Frees any resources used by the LSPSRequestId, if is_owned is set and inner is non-NULL. */ -void NodeFeatures_set_taproot_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPSRequestId_free(struct LDKLSPSRequestId this_obj); + +struct LDKStr LSPSRequestId_get_a(const struct LDKLSPSRequestId *NONNULL_PTR this_ptr); + +void LSPSRequestId_set_a(struct LDKLSPSRequestId *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Set this feature as required. + * Constructs a new LSPSRequestId given each field */ -void NodeFeatures_set_taproot_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPSRequestId LSPSRequestId_new(struct LDKStr a_arg); /** - * Checks if this feature is supported. + * Creates a copy of the LSPSRequestId */ -MUST_USE_RES bool NodeFeatures_supports_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKLSPSRequestId LSPSRequestId_clone(const struct LDKLSPSRequestId *NONNULL_PTR orig); /** - * Set this feature as optional. + * Checks if two LSPSRequestIds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelTypeFeatures_set_taproot_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +bool LSPSRequestId_eq(const struct LDKLSPSRequestId *NONNULL_PTR a, const struct LDKLSPSRequestId *NONNULL_PTR b); /** - * Set this feature as required. + * Generates a non-cryptographic 64-bit hash of the LSPSRequestId. */ -void ChannelTypeFeatures_set_taproot_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +uint64_t LSPSRequestId_hash(const struct LDKLSPSRequestId *NONNULL_PTR o); /** - * Checks if this feature is supported. + * Frees any resources used by the LSPSDateTime, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void LSPSDateTime_free(struct LDKLSPSDateTime this_obj); /** - * Checks if this feature is required. + * Creates a copy of the LSPSDateTime */ -MUST_USE_RES bool InitFeatures_requires_taproot(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPSDateTime LSPSDateTime_clone(const struct LDKLSPSDateTime *NONNULL_PTR orig); /** - * Checks if this feature is required. + * Checks if two LSPSDateTimes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool NodeFeatures_requires_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +bool LSPSDateTime_eq(const struct LDKLSPSDateTime *NONNULL_PTR a, const struct LDKLSPSDateTime *NONNULL_PTR b); /** - * Checks if this feature is required. + * Generates a non-cryptographic 64-bit hash of the LSPSDateTime. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +uint64_t LSPSDateTime_hash(const struct LDKLSPSDateTime *NONNULL_PTR o); /** - * Set this feature as optional. + * Returns the LSPSDateTime as RFC3339 formatted string. */ -void InitFeatures_set_onion_messages_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKStr LSPSDateTime_to_rfc3339(const struct LDKLSPSDateTime *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Returns if the given time is in the past. */ -void InitFeatures_set_onion_messages_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool LSPSDateTime_is_past(const struct LDKLSPSDateTime *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Read a LSPSDateTime object from a string */ -MUST_USE_RES bool InitFeatures_supports_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCResult_LSPSDateTimeNoneZ LSPSDateTime_from_str(struct LDKStr s); /** - * Set this feature as optional. + * Get the string representation of a LSPSDateTime object */ -void NodeFeatures_set_onion_messages_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKStr LSPSDateTime_to_str(const struct LDKLSPSDateTime *NONNULL_PTR o); /** - * Set this feature as required. + * Frees any resources used by the LSPSResponseError, if is_owned is set and inner is non-NULL. */ -void NodeFeatures_set_onion_messages_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPSResponseError_free(struct LDKLSPSResponseError this_obj); /** - * Checks if this feature is supported. + * A string providing a short description of the error. */ -MUST_USE_RES bool NodeFeatures_supports_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKStr LSPSResponseError_get_message(const struct LDKLSPSResponseError *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * A string providing a short description of the error. */ -MUST_USE_RES bool InitFeatures_requires_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void LSPSResponseError_set_message(struct LDKLSPSResponseError *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Checks if this feature is required. + * A primitive or structured value that contains additional information about the error. */ -MUST_USE_RES bool NodeFeatures_requires_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCOption_StrZ LSPSResponseError_get_data(const struct LDKLSPSResponseError *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * A primitive or structured value that contains additional information about the error. */ -void InitFeatures_set_channel_type_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void LSPSResponseError_set_data(struct LDKLSPSResponseError *NONNULL_PTR this_ptr, struct LDKCOption_StrZ val); /** - * Set this feature as required. + * Creates a copy of the LSPSResponseError */ -void InitFeatures_set_channel_type_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPSResponseError LSPSResponseError_clone(const struct LDKLSPSResponseError *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Checks if two LSPSResponseErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool InitFeatures_supports_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); +bool LSPSResponseError_eq(const struct LDKLSPSResponseError *NONNULL_PTR a, const struct LDKLSPSResponseError *NONNULL_PTR b); /** - * Set this feature as optional. + * Frees any resources used by the LSPSMessage */ -void NodeFeatures_set_channel_type_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPSMessage_free(struct LDKLSPSMessage this_ptr); /** - * Set this feature as required. + * Creates a copy of the LSPSMessage */ -void NodeFeatures_set_channel_type_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKLSPSMessage LSPSMessage_clone(const struct LDKLSPSMessage *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Utility method to constructs a new Invalid-variant LSPSMessage */ -MUST_USE_RES bool NodeFeatures_supports_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKLSPSMessage LSPSMessage_invalid(struct LDKLSPSResponseError a); /** - * Checks if this feature is required. + * Utility method to constructs a new LSPS0-variant LSPSMessage */ -MUST_USE_RES bool InitFeatures_requires_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPSMessage LSPSMessage_lsps0(struct LDKLSPS0Message a); /** - * Checks if this feature is required. + * Utility method to constructs a new LSPS1-variant LSPSMessage */ -MUST_USE_RES bool NodeFeatures_requires_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKLSPSMessage LSPSMessage_lsps1(struct LDKLSPS1Message a); /** - * Set this feature as optional. + * Utility method to constructs a new LSPS2-variant LSPSMessage */ -void InitFeatures_set_scid_privacy_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPSMessage LSPSMessage_lsps2(struct LDKLSPS2Message a); /** - * Set this feature as required. + * Checks if two LSPSMessages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void InitFeatures_set_scid_privacy_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +bool LSPSMessage_eq(const struct LDKLSPSMessage *NONNULL_PTR a, const struct LDKLSPSMessage *NONNULL_PTR b); /** - * Checks if this feature is supported. + * Frees any resources used by the LSPS0ServiceHandler, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_supports_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void LSPS0ServiceHandler_free(struct LDKLSPS0ServiceHandler this_obj); /** - * Set this feature as optional. + * Frees any resources used by the LSPS1ClientConfig, if is_owned is set and inner is non-NULL. */ -void NodeFeatures_set_scid_privacy_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS1ClientConfig_free(struct LDKLSPS1ClientConfig this_obj); /** - * Set this feature as required. + * The maximally allowed channel fees. */ -void NodeFeatures_set_scid_privacy_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCOption_u64Z LSPS1ClientConfig_get_max_channel_fees_msat(const struct LDKLSPS1ClientConfig *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * The maximally allowed channel fees. */ -MUST_USE_RES bool NodeFeatures_supports_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS1ClientConfig_set_max_channel_fees_msat(struct LDKLSPS1ClientConfig *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Set this feature as optional. + * Constructs a new LSPS1ClientConfig given each field */ -void ChannelTypeFeatures_set_scid_privacy_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPS1ClientConfig LSPS1ClientConfig_new(struct LDKCOption_u64Z max_channel_fees_msat_arg); /** - * Set this feature as required. + * Creates a copy of the LSPS1ClientConfig */ -void ChannelTypeFeatures_set_scid_privacy_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKLSPS1ClientConfig LSPS1ClientConfig_clone(const struct LDKLSPS1ClientConfig *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Frees any resources used by the LSPS1ClientHandler, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void LSPS1ClientHandler_free(struct LDKLSPS1ClientHandler this_obj); /** - * Checks if this feature is required. + * Request the supported options from the LSP. + * + * The user will receive the LSP's response via an [`SupportedOptionsReady`] event. + * + * `counterparty_node_id` is the `node_id` of the LSP you would like to use. + * + * Returns the used [`LSPSRequestId`], which will be returned via [`SupportedOptionsReady`]. + * + * [`SupportedOptionsReady`]: crate::lsps1::event::LSPS1ClientEvent::SupportedOptionsReady */ -MUST_USE_RES bool InitFeatures_requires_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPSRequestId LSPS1ClientHandler_request_supported_options(const struct LDKLSPS1ClientHandler *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id); /** - * Checks if this feature is required. + * Places an order with the connected LSP given its `counterparty_node_id`. + * + * The client agrees to paying channel fees according to the provided parameters. */ -MUST_USE_RES bool NodeFeatures_requires_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPSRequestId LSPS1ClientHandler_create_order(const struct LDKLSPS1ClientHandler *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKLSPS1OrderParams order, struct LDKCOption_AddressZ refund_onchain_address); /** - * Checks if this feature is required. + * Queries the status of a pending payment, i.e., whether a payment has been received by the LSP. + * + * Upon success an [`LSPS1ClientEvent::OrderStatus`] event will be emitted. + * + * [`LSPS1ClientEvent::OrderStatus`]: crate::lsps1::event::LSPS1ClientEvent::OrderStatus */ -MUST_USE_RES bool ChannelTypeFeatures_requires_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPSRequestId LSPS1ClientHandler_check_order_status(const struct LDKLSPS1ClientHandler *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKLSPS1OrderId order_id); /** - * Set this feature as optional. + * Frees any resources used by the LSPS1ClientEvent */ -void Bolt11InvoiceFeatures_set_payment_metadata_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +void LSPS1ClientEvent_free(struct LDKLSPS1ClientEvent this_ptr); /** - * Set this feature as required. + * Creates a copy of the LSPS1ClientEvent */ -void Bolt11InvoiceFeatures_set_payment_metadata_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKLSPS1ClientEvent LSPS1ClientEvent_clone(const struct LDKLSPS1ClientEvent *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Utility method to constructs a new SupportedOptionsReady-variant LSPS1ClientEvent */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKLSPS1ClientEvent LSPS1ClientEvent_supported_options_ready(struct LDKLSPSRequestId request_id, struct LDKPublicKey counterparty_node_id, struct LDKLSPS1Options supported_options); /** - * Checks if this feature is required. + * Utility method to constructs a new SupportedOptionsRequestFailed-variant LSPS1ClientEvent */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKLSPS1ClientEvent LSPS1ClientEvent_supported_options_request_failed(struct LDKLSPSRequestId request_id, struct LDKPublicKey counterparty_node_id, struct LDKLSPSResponseError error); /** - * Set this feature as optional. + * Utility method to constructs a new OrderCreated-variant LSPS1ClientEvent */ -void InitFeatures_set_zero_conf_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPS1ClientEvent LSPS1ClientEvent_order_created(struct LDKLSPSRequestId request_id, struct LDKPublicKey counterparty_node_id, struct LDKLSPS1OrderId order_id, struct LDKLSPS1OrderParams order, struct LDKLSPS1PaymentInfo payment, struct LDKLSPS1ChannelInfo channel); /** - * Set this feature as required. + * Utility method to constructs a new OrderStatus-variant LSPS1ClientEvent */ -void InitFeatures_set_zero_conf_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPS1ClientEvent LSPS1ClientEvent_order_status(struct LDKLSPSRequestId request_id, struct LDKPublicKey counterparty_node_id, struct LDKLSPS1OrderId order_id, struct LDKLSPS1OrderParams order, struct LDKLSPS1PaymentInfo payment, struct LDKLSPS1ChannelInfo channel); /** - * Checks if this feature is supported. + * Utility method to constructs a new OrderRequestFailed-variant LSPS1ClientEvent */ -MUST_USE_RES bool InitFeatures_supports_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKLSPS1ClientEvent LSPS1ClientEvent_order_request_failed(struct LDKLSPSRequestId request_id, struct LDKPublicKey counterparty_node_id, struct LDKLSPSResponseError error); /** - * Set this feature as optional. + * Checks if two LSPS1ClientEvents contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void NodeFeatures_set_zero_conf_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +bool LSPS1ClientEvent_eq(const struct LDKLSPS1ClientEvent *NONNULL_PTR a, const struct LDKLSPS1ClientEvent *NONNULL_PTR b); /** - * Set this feature as required. + * Frees any resources used by the LSPS1OrderId, if is_owned is set and inner is non-NULL. */ -void NodeFeatures_set_zero_conf_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS1OrderId_free(struct LDKLSPS1OrderId this_obj); + +struct LDKStr LSPS1OrderId_get_a(const struct LDKLSPS1OrderId *NONNULL_PTR this_ptr); + +void LSPS1OrderId_set_a(struct LDKLSPS1OrderId *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Checks if this feature is supported. + * Constructs a new LSPS1OrderId given each field */ -MUST_USE_RES bool NodeFeatures_supports_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPS1OrderId LSPS1OrderId_new(struct LDKStr a_arg); /** - * Set this feature as optional. + * Creates a copy of the LSPS1OrderId */ -void ChannelTypeFeatures_set_zero_conf_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKLSPS1OrderId LSPS1OrderId_clone(const struct LDKLSPS1OrderId *NONNULL_PTR orig); /** - * Set this feature as required. + * Checks if two LSPS1OrderIds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelTypeFeatures_set_zero_conf_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +bool LSPS1OrderId_eq(const struct LDKLSPS1OrderId *NONNULL_PTR a, const struct LDKLSPS1OrderId *NONNULL_PTR b); /** - * Checks if this feature is supported. + * Generates a non-cryptographic 64-bit hash of the LSPS1OrderId. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +uint64_t LSPS1OrderId_hash(const struct LDKLSPS1OrderId *NONNULL_PTR o); /** - * Checks if this feature is required. + * Frees any resources used by the LSPS1GetInfoRequest, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_requires_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void LSPS1GetInfoRequest_free(struct LDKLSPS1GetInfoRequest this_obj); /** - * Checks if this feature is required. + * Constructs a new LSPS1GetInfoRequest given each field */ -MUST_USE_RES bool NodeFeatures_requires_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPS1GetInfoRequest LSPS1GetInfoRequest_new(void); /** - * Checks if this feature is required. + * Creates a copy of the LSPS1GetInfoRequest */ -MUST_USE_RES bool ChannelTypeFeatures_requires_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKLSPS1GetInfoRequest LSPS1GetInfoRequest_clone(const struct LDKLSPS1GetInfoRequest *NONNULL_PTR orig); /** - * Set this feature as optional. + * Checks if two LSPS1GetInfoRequests contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void NodeFeatures_set_keysend_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +bool LSPS1GetInfoRequest_eq(const struct LDKLSPS1GetInfoRequest *NONNULL_PTR a, const struct LDKLSPS1GetInfoRequest *NONNULL_PTR b); /** - * Set this feature as required. + * Frees any resources used by the LSPS1Options, if is_owned is set and inner is non-NULL. */ -void NodeFeatures_set_keysend_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS1Options_free(struct LDKLSPS1Options this_obj); /** - * Checks if this feature is supported. + * The smallest number of confirmations needed for the LSP to accept a channel as confirmed. */ -MUST_USE_RES bool NodeFeatures_supports_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint16_t LSPS1Options_get_min_required_channel_confirmations(const struct LDKLSPS1Options *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * The smallest number of confirmations needed for the LSP to accept a channel as confirmed. */ -MUST_USE_RES bool NodeFeatures_requires_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS1Options_set_min_required_channel_confirmations(struct LDKLSPS1Options *NONNULL_PTR this_ptr, uint16_t val); /** - * Set this feature as optional. + * The smallest number of blocks in which the LSP can confirm the funding transaction. */ -void InitFeatures_set_trampoline_routing_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +uint16_t LSPS1Options_get_min_funding_confirms_within_blocks(const struct LDKLSPS1Options *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The smallest number of blocks in which the LSP can confirm the funding transaction. */ -void InitFeatures_set_trampoline_routing_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void LSPS1Options_set_min_funding_confirms_within_blocks(struct LDKLSPS1Options *NONNULL_PTR this_ptr, uint16_t val); /** - * Checks if this feature is supported. + * Indicates if the LSP supports zero reserve. */ -MUST_USE_RES bool InitFeatures_supports_trampoline_routing(const struct LDKInitFeatures *NONNULL_PTR this_arg); +bool LSPS1Options_get_supports_zero_channel_reserve(const struct LDKLSPS1Options *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * Indicates if the LSP supports zero reserve. */ -void NodeFeatures_set_trampoline_routing_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS1Options_set_supports_zero_channel_reserve(struct LDKLSPS1Options *NONNULL_PTR this_ptr, bool val); /** - * Set this feature as required. + * The maximum number of blocks a channel can be leased for. */ -void NodeFeatures_set_trampoline_routing_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint32_t LSPS1Options_get_max_channel_expiry_blocks(const struct LDKLSPS1Options *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * The maximum number of blocks a channel can be leased for. */ -MUST_USE_RES bool NodeFeatures_supports_trampoline_routing(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS1Options_set_max_channel_expiry_blocks(struct LDKLSPS1Options *NONNULL_PTR this_ptr, uint32_t val); /** - * Set this feature as optional. + * The minimum number of satoshi that the client MUST request. */ -void Bolt11InvoiceFeatures_set_trampoline_routing_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +uint64_t LSPS1Options_get_min_initial_client_balance_sat(const struct LDKLSPS1Options *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The minimum number of satoshi that the client MUST request. */ -void Bolt11InvoiceFeatures_set_trampoline_routing_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +void LSPS1Options_set_min_initial_client_balance_sat(struct LDKLSPS1Options *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if this feature is supported. + * The maximum number of satoshi that the client MUST request. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_trampoline_routing(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +uint64_t LSPS1Options_get_max_initial_client_balance_sat(const struct LDKLSPS1Options *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * The maximum number of satoshi that the client MUST request. */ -void Bolt12InvoiceFeatures_set_trampoline_routing_optional(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +void LSPS1Options_set_max_initial_client_balance_sat(struct LDKLSPS1Options *NONNULL_PTR this_ptr, uint64_t val); /** - * Set this feature as required. + * The minimum number of satoshi that the LSP will provide to the channel. */ -void Bolt12InvoiceFeatures_set_trampoline_routing_required(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +uint64_t LSPS1Options_get_min_initial_lsp_balance_sat(const struct LDKLSPS1Options *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * The minimum number of satoshi that the LSP will provide to the channel. */ -MUST_USE_RES bool Bolt12InvoiceFeatures_supports_trampoline_routing(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +void LSPS1Options_set_min_initial_lsp_balance_sat(struct LDKLSPS1Options *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if this feature is required. + * The maximum number of satoshi that the LSP will provide to the channel. */ -MUST_USE_RES bool InitFeatures_requires_trampoline_routing(const struct LDKInitFeatures *NONNULL_PTR this_arg); +uint64_t LSPS1Options_get_max_initial_lsp_balance_sat(const struct LDKLSPS1Options *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * The maximum number of satoshi that the LSP will provide to the channel. */ -MUST_USE_RES bool NodeFeatures_requires_trampoline_routing(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS1Options_set_max_initial_lsp_balance_sat(struct LDKLSPS1Options *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if this feature is required. + * The minimal channel size. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_trampoline_routing(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +uint64_t LSPS1Options_get_min_channel_balance_sat(const struct LDKLSPS1Options *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * The minimal channel size. */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_trampoline_routing(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +void LSPS1Options_set_min_channel_balance_sat(struct LDKLSPS1Options *NONNULL_PTR this_ptr, uint64_t val); /** - * Set this feature as optional. + * The maximal channel size. */ -void NodeFeatures_set_dns_resolution_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint64_t LSPS1Options_get_max_channel_balance_sat(const struct LDKLSPS1Options *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The maximal channel size. */ -void NodeFeatures_set_dns_resolution_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void LSPS1Options_set_max_channel_balance_sat(struct LDKLSPS1Options *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if this feature is supported. + * Constructs a new LSPS1Options given each field */ -MUST_USE_RES bool NodeFeatures_supports_dns_resolution(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPS1Options LSPS1Options_new(uint16_t min_required_channel_confirmations_arg, uint16_t min_funding_confirms_within_blocks_arg, bool supports_zero_channel_reserve_arg, uint32_t max_channel_expiry_blocks_arg, uint64_t min_initial_client_balance_sat_arg, uint64_t max_initial_client_balance_sat_arg, uint64_t min_initial_lsp_balance_sat_arg, uint64_t max_initial_lsp_balance_sat_arg, uint64_t min_channel_balance_sat_arg, uint64_t max_channel_balance_sat_arg); /** - * Checks if this feature is required. + * Creates a copy of the LSPS1Options */ -MUST_USE_RES bool NodeFeatures_requires_dns_resolution(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKLSPS1Options LSPS1Options_clone(const struct LDKLSPS1Options *NONNULL_PTR orig); /** - * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. + * Checks if two LSPS1Optionss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void RoutingFees_free(struct LDKRoutingFees this_obj); +bool LSPS1Options_eq(const struct LDKLSPS1Options *NONNULL_PTR a, const struct LDKLSPS1Options *NONNULL_PTR b); /** - * Flat routing fee in millisatoshis. + * Frees any resources used by the LSPS1GetInfoResponse, if is_owned is set and inner is non-NULL. */ -uint32_t RoutingFees_get_base_msat(const struct LDKRoutingFees *NONNULL_PTR this_ptr); +void LSPS1GetInfoResponse_free(struct LDKLSPS1GetInfoResponse this_obj); /** - * Flat routing fee in millisatoshis. + * All options supported by the LSP. */ -void RoutingFees_set_base_msat(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); +struct LDKLSPS1Options LSPS1GetInfoResponse_get_options(const struct LDKLSPS1GetInfoResponse *NONNULL_PTR this_ptr); /** - * Liquidity-based routing fee in millionths of a routed amount. - * In other words, 10000 is 1%. + * All options supported by the LSP. */ -uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *NONNULL_PTR this_ptr); +void LSPS1GetInfoResponse_set_options(struct LDKLSPS1GetInfoResponse *NONNULL_PTR this_ptr, struct LDKLSPS1Options val); /** - * Liquidity-based routing fee in millionths of a routed amount. - * In other words, 10000 is 1%. + * Constructs a new LSPS1GetInfoResponse given each field */ -void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKLSPS1GetInfoResponse LSPS1GetInfoResponse_new(struct LDKLSPS1Options options_arg); /** - * Constructs a new RoutingFees given each field + * Creates a copy of the LSPS1GetInfoResponse */ -MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); +struct LDKLSPS1GetInfoResponse LSPS1GetInfoResponse_clone(const struct LDKLSPS1GetInfoResponse *NONNULL_PTR orig); /** - * Checks if two RoutingFeess contain equal inner contents. + * Checks if two LSPS1GetInfoResponses contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool RoutingFees_eq(const struct LDKRoutingFees *NONNULL_PTR a, const struct LDKRoutingFees *NONNULL_PTR b); +bool LSPS1GetInfoResponse_eq(const struct LDKLSPS1GetInfoResponse *NONNULL_PTR a, const struct LDKLSPS1GetInfoResponse *NONNULL_PTR b); /** - * Creates a copy of the RoutingFees + * Frees any resources used by the LSPS1CreateOrderRequest, if is_owned is set and inner is non-NULL. */ -struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); +void LSPS1CreateOrderRequest_free(struct LDKLSPS1CreateOrderRequest this_obj); /** - * Generates a non-cryptographic 64-bit hash of the RoutingFees. + * The order made. */ -uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o); +struct LDKLSPS1OrderParams LSPS1CreateOrderRequest_get_order(const struct LDKLSPS1CreateOrderRequest *NONNULL_PTR this_ptr); /** - * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. + * The order made. */ -void RouteHint_free(struct LDKRouteHint this_obj); - -struct LDKCVec_RouteHintHopZ RouteHint_get_a(const struct LDKRouteHint *NONNULL_PTR this_ptr); +void LSPS1CreateOrderRequest_set_order(struct LDKLSPS1CreateOrderRequest *NONNULL_PTR this_ptr, struct LDKLSPS1OrderParams val); -void RouteHint_set_a(struct LDKRouteHint *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintHopZ val); +/** + * The address where the LSP will send the funds if the order fails. + */ +struct LDKCOption_AddressZ LSPS1CreateOrderRequest_get_refund_onchain_address(const struct LDKLSPS1CreateOrderRequest *NONNULL_PTR this_ptr); /** - * Constructs a new RouteHint given each field + * The address where the LSP will send the funds if the order fails. */ -MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKCVec_RouteHintHopZ a_arg); +void LSPS1CreateOrderRequest_set_refund_onchain_address(struct LDKLSPS1CreateOrderRequest *NONNULL_PTR this_ptr, struct LDKCOption_AddressZ val); /** - * Creates a copy of the RouteHint + * Constructs a new LSPS1CreateOrderRequest given each field */ -struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); +MUST_USE_RES struct LDKLSPS1CreateOrderRequest LSPS1CreateOrderRequest_new(struct LDKLSPS1OrderParams order_arg, struct LDKCOption_AddressZ refund_onchain_address_arg); /** - * Generates a non-cryptographic 64-bit hash of the RouteHint. + * Creates a copy of the LSPS1CreateOrderRequest */ -uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o); +struct LDKLSPS1CreateOrderRequest LSPS1CreateOrderRequest_clone(const struct LDKLSPS1CreateOrderRequest *NONNULL_PTR orig); /** - * Checks if two RouteHints contain equal inner contents. + * Checks if two LSPS1CreateOrderRequests contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); +bool LSPS1CreateOrderRequest_eq(const struct LDKLSPS1CreateOrderRequest *NONNULL_PTR a, const struct LDKLSPS1CreateOrderRequest *NONNULL_PTR b); /** - * Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. + * Frees any resources used by the LSPS1OrderParams, if is_owned is set and inner is non-NULL. */ -void RouteHintHop_free(struct LDKRouteHintHop this_obj); +void LSPS1OrderParams_free(struct LDKLSPS1OrderParams this_obj); /** - * The node_id of the non-target end of the route + * Indicates how many satoshi the LSP will provide on their side. */ -struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +uint64_t LSPS1OrderParams_get_lsp_balance_sat(const struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr); /** - * The node_id of the non-target end of the route + * Indicates how many satoshi the LSP will provide on their side. */ -void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void LSPS1OrderParams_set_lsp_balance_sat(struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr, uint64_t val); /** - * The short_channel_id of this channel + * Indicates how many satoshi the client will provide on their side. + * + * The client sends these funds to the LSP, who will push them back to the client upon opening + * the channel. */ -uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +uint64_t LSPS1OrderParams_get_client_balance_sat(const struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr); /** - * The short_channel_id of this channel + * Indicates how many satoshi the client will provide on their side. + * + * The client sends these funds to the LSP, who will push them back to the client upon opening + * the channel. */ -void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t val); +void LSPS1OrderParams_set_client_balance_sat(struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr, uint64_t val); /** - * The fees which must be paid to use this channel + * The number of confirmations the funding tx must have before the LSP sends `channel_ready`. */ -struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +uint16_t LSPS1OrderParams_get_required_channel_confirmations(const struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr); /** - * The fees which must be paid to use this channel + * The number of confirmations the funding tx must have before the LSP sends `channel_ready`. */ -void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +void LSPS1OrderParams_set_required_channel_confirmations(struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr, uint16_t val); /** - * The difference in CLTV values between this node and the next node. + * The maximum number of blocks the client wants to wait until the funding transaction is confirmed. */ -uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +uint16_t LSPS1OrderParams_get_funding_confirms_within_blocks(const struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr); /** - * The difference in CLTV values between this node and the next node. + * The maximum number of blocks the client wants to wait until the funding transaction is confirmed. */ -void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val); +void LSPS1OrderParams_set_funding_confirms_within_blocks(struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr, uint16_t val); /** - * The minimum value, in msat, which must be relayed to the next hop. + * Indicates how long the channel is leased for in block time. */ -struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +uint32_t LSPS1OrderParams_get_channel_expiry_blocks(const struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr); /** - * The minimum value, in msat, which must be relayed to the next hop. + * Indicates how long the channel is leased for in block time. */ -void RouteHintHop_set_htlc_minimum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void LSPS1OrderParams_set_channel_expiry_blocks(struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr, uint32_t val); /** - * The maximum value in msat available for routing with a single HTLC. + * May contain arbitrary associated data like a coupon code or a authentication token. */ -struct LDKCOption_u64Z RouteHintHop_get_htlc_maximum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKCOption_StrZ LSPS1OrderParams_get_token(const struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr); /** - * The maximum value in msat available for routing with a single HTLC. + * May contain arbitrary associated data like a coupon code or a authentication token. */ -void RouteHintHop_set_htlc_maximum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void LSPS1OrderParams_set_token(struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr, struct LDKCOption_StrZ val); /** - * Constructs a new RouteHintHop given each field + * Indicates if the channel should be announced to the network. */ -MUST_USE_RES struct LDKRouteHintHop RouteHintHop_new(struct LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, struct LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, struct LDKCOption_u64Z htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg); +bool LSPS1OrderParams_get_announce_channel(const struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr); /** - * Creates a copy of the RouteHintHop + * Indicates if the channel should be announced to the network. */ -struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); +void LSPS1OrderParams_set_announce_channel(struct LDKLSPS1OrderParams *NONNULL_PTR this_ptr, bool val); /** - * Generates a non-cryptographic 64-bit hash of the RouteHintHop. + * Constructs a new LSPS1OrderParams given each field */ -uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o); +MUST_USE_RES struct LDKLSPS1OrderParams LSPS1OrderParams_new(uint64_t lsp_balance_sat_arg, uint64_t client_balance_sat_arg, uint16_t required_channel_confirmations_arg, uint16_t funding_confirms_within_blocks_arg, uint32_t channel_expiry_blocks_arg, struct LDKCOption_StrZ token_arg, bool announce_channel_arg); /** - * Checks if two RouteHintHops contain equal inner contents. + * Creates a copy of the LSPS1OrderParams + */ +struct LDKLSPS1OrderParams LSPS1OrderParams_clone(const struct LDKLSPS1OrderParams *NONNULL_PTR orig); + +/** + * Checks if two LSPS1OrderParamss contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); +bool LSPS1OrderParams_eq(const struct LDKLSPS1OrderParams *NONNULL_PTR a, const struct LDKLSPS1OrderParams *NONNULL_PTR b); /** - * Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. + * Frees any resources used by the LSPS1CreateOrderResponse, if is_owned is set and inner is non-NULL. */ -void UntrustedString_free(struct LDKUntrustedString this_obj); - -struct LDKStr UntrustedString_get_a(const struct LDKUntrustedString *NONNULL_PTR this_ptr); +void LSPS1CreateOrderResponse_free(struct LDKLSPS1CreateOrderResponse this_obj); -void UntrustedString_set_a(struct LDKUntrustedString *NONNULL_PTR this_ptr, struct LDKStr val); +/** + * The id of the channel order. + */ +struct LDKLSPS1OrderId LSPS1CreateOrderResponse_get_order_id(const struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr); /** - * Constructs a new UntrustedString given each field + * The id of the channel order. */ -MUST_USE_RES struct LDKUntrustedString UntrustedString_new(struct LDKStr a_arg); +void LSPS1CreateOrderResponse_set_order_id(struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr, struct LDKLSPS1OrderId val); /** - * Creates a copy of the UntrustedString + * The parameters of channel order. */ -struct LDKUntrustedString UntrustedString_clone(const struct LDKUntrustedString *NONNULL_PTR orig); +struct LDKLSPS1OrderParams LSPS1CreateOrderResponse_get_order(const struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr); /** - * Checks if two UntrustedStrings contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The parameters of channel order. */ -bool UntrustedString_eq(const struct LDKUntrustedString *NONNULL_PTR a, const struct LDKUntrustedString *NONNULL_PTR b); +void LSPS1CreateOrderResponse_set_order(struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr, struct LDKLSPS1OrderParams val); /** - * Generates a non-cryptographic 64-bit hash of the UntrustedString. + * The datetime when the order was created */ -uint64_t UntrustedString_hash(const struct LDKUntrustedString *NONNULL_PTR o); +struct LDKLSPSDateTime LSPS1CreateOrderResponse_get_created_at(const struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr); /** - * Get the string representation of a UntrustedString object + * The datetime when the order was created */ -struct LDKStr UntrustedString_to_str(const struct LDKUntrustedString *NONNULL_PTR o); +void LSPS1CreateOrderResponse_set_created_at(struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr, struct LDKLSPSDateTime val); /** - * Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. + * The current state of the order. */ -void PrintableString_free(struct LDKPrintableString this_obj); +enum LDKLSPS1OrderState LSPS1CreateOrderResponse_get_order_state(const struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr); -struct LDKStr PrintableString_get_a(const struct LDKPrintableString *NONNULL_PTR this_ptr); +/** + * The current state of the order. + */ +void LSPS1CreateOrderResponse_set_order_state(struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr, enum LDKLSPS1OrderState val); -void PrintableString_set_a(struct LDKPrintableString *NONNULL_PTR this_ptr, struct LDKStr val); +/** + * Contains details about how to pay for the order. + */ +struct LDKLSPS1PaymentInfo LSPS1CreateOrderResponse_get_payment(const struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr); /** - * Constructs a new PrintableString given each field + * Contains details about how to pay for the order. */ -MUST_USE_RES struct LDKPrintableString PrintableString_new(struct LDKStr a_arg); +void LSPS1CreateOrderResponse_set_payment(struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr, struct LDKLSPS1PaymentInfo val); /** - * Get the string representation of a PrintableString object + * Contains information about the channel state. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKStr PrintableString_to_str(const struct LDKPrintableString *NONNULL_PTR o); +struct LDKLSPS1ChannelInfo LSPS1CreateOrderResponse_get_channel(const struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr); /** - * Frees any resources used by the FilesystemStore, if is_owned is set and inner is non-NULL. + * Contains information about the channel state. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void FilesystemStore_free(struct LDKFilesystemStore this_obj); +void LSPS1CreateOrderResponse_set_channel(struct LDKLSPS1CreateOrderResponse *NONNULL_PTR this_ptr, struct LDKLSPS1ChannelInfo val); /** - * Constructs a new [`FilesystemStore`]. + * Constructs a new LSPS1CreateOrderResponse given each field + * + * Note that channel_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKFilesystemStore FilesystemStore_new(struct LDKStr data_dir); +MUST_USE_RES struct LDKLSPS1CreateOrderResponse LSPS1CreateOrderResponse_new(struct LDKLSPS1OrderId order_id_arg, struct LDKLSPS1OrderParams order_arg, struct LDKLSPSDateTime created_at_arg, enum LDKLSPS1OrderState order_state_arg, struct LDKLSPS1PaymentInfo payment_arg, struct LDKLSPS1ChannelInfo channel_arg); /** - * Returns the data directory. + * Creates a copy of the LSPS1CreateOrderResponse */ -MUST_USE_RES struct LDKStr FilesystemStore_get_data_dir(const struct LDKFilesystemStore *NONNULL_PTR this_arg); +struct LDKLSPS1CreateOrderResponse LSPS1CreateOrderResponse_clone(const struct LDKLSPS1CreateOrderResponse *NONNULL_PTR orig); /** - * Constructs a new KVStore which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned KVStore must be freed before this_arg is + * Checks if two LSPS1CreateOrderResponses contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKKVStore FilesystemStore_as_KVStore(const struct LDKFilesystemStore *NONNULL_PTR this_arg); +bool LSPS1CreateOrderResponse_eq(const struct LDKLSPS1CreateOrderResponse *NONNULL_PTR a, const struct LDKLSPS1CreateOrderResponse *NONNULL_PTR b); /** - * Constructs a new MigratableKVStore which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MigratableKVStore must be freed before this_arg is + * Creates a copy of the LSPS1OrderState */ -struct LDKMigratableKVStore FilesystemStore_as_MigratableKVStore(const struct LDKFilesystemStore *NONNULL_PTR this_arg); +enum LDKLSPS1OrderState LSPS1OrderState_clone(const enum LDKLSPS1OrderState *NONNULL_PTR orig); /** - * Frees any resources used by the BackgroundProcessor, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Created-variant LSPS1OrderState */ -void BackgroundProcessor_free(struct LDKBackgroundProcessor this_obj); +enum LDKLSPS1OrderState LSPS1OrderState_created(void); /** - * Frees any resources used by the GossipSync + * Utility method to constructs a new Completed-variant LSPS1OrderState */ -void GossipSync_free(struct LDKGossipSync this_ptr); +enum LDKLSPS1OrderState LSPS1OrderState_completed(void); /** - * Utility method to constructs a new P2P-variant GossipSync + * Utility method to constructs a new Failed-variant LSPS1OrderState */ -struct LDKGossipSync GossipSync_p2_p(const struct LDKP2PGossipSync *NONNULL_PTR a); +enum LDKLSPS1OrderState LSPS1OrderState_failed(void); /** - * Utility method to constructs a new Rapid-variant GossipSync + * Checks if two LSPS1OrderStates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKGossipSync GossipSync_rapid(const struct LDKRapidGossipSync *NONNULL_PTR a); +bool LSPS1OrderState_eq(const enum LDKLSPS1OrderState *NONNULL_PTR a, const enum LDKLSPS1OrderState *NONNULL_PTR b); /** - * Utility method to constructs a new None-variant GossipSync + * Frees any resources used by the LSPS1PaymentInfo, if is_owned is set and inner is non-NULL. */ -struct LDKGossipSync GossipSync_none(void); +void LSPS1PaymentInfo_free(struct LDKLSPS1PaymentInfo this_obj); /** - * Start a background thread that takes care of responsibilities enumerated in the [top-level - * documentation]. - * - * The thread runs indefinitely unless the object is dropped, [`stop`] is called, or - * [`Persister::persist_manager`] returns an error. In case of an error, the error is retrieved by calling - * either [`join`] or [`stop`]. - * - * # Data Persistence - * - * [`Persister::persist_manager`] is responsible for writing out the [`ChannelManager`] to disk, and/or - * uploading to one or more backup services. See [`ChannelManager::write`] for writing out a - * [`ChannelManager`]. See the `lightning-persister` crate for LDK's - * provided implementation. - * - * [`Persister::persist_graph`] is responsible for writing out the [`NetworkGraph`] to disk, if - * [`GossipSync`] is supplied. See [`NetworkGraph::write`] for writing out a [`NetworkGraph`]. - * See the `lightning-persister` crate for LDK's provided implementation. - * - * Typically, users should either implement [`Persister::persist_manager`] to never return an - * error or call [`join`] and handle any error that may arise. For the latter case, - * `BackgroundProcessor` must be restarted by calling `start` again after handling the error. - * - * # Event Handling - * - * `event_handler` is responsible for handling events that users should be notified of (e.g., - * payment failed). [`BackgroundProcessor`] may decorate the given [`EventHandler`] with common - * functionality implemented by other handlers. - * * [`P2PGossipSync`] if given will update the [`NetworkGraph`] based on payment failures. - * - * # Rapid Gossip Sync - * - * If rapid gossip sync is meant to run at startup, pass [`RapidGossipSync`] via `gossip_sync` - * to indicate that the [`BackgroundProcessor`] should not prune the [`NetworkGraph`] instance - * until the [`RapidGossipSync`] instance completes its first sync. + * A Lightning payment using BOLT 11. * - * [top-level documentation]: BackgroundProcessor - * [`join`]: Self::join - * [`stop`]: Self::stop - * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager - * [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable - * [`Persister::persist_manager`]: lightning::util::persist::Persister::persist_manager - * [`Persister::persist_graph`]: lightning::util::persist::Persister::persist_graph - * [`NetworkGraph`]: lightning::routing::gossip::NetworkGraph - * [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, const struct LDKOnionMessenger *NONNULL_PTR onion_messenger, struct LDKGossipSync gossip_sync, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger, struct LDKCOption_WriteableScoreZ scorer); +struct LDKLSPS1Bolt11PaymentInfo LSPS1PaymentInfo_get_bolt11(const struct LDKLSPS1PaymentInfo *NONNULL_PTR this_ptr); /** - * Join `BackgroundProcessor`'s thread, returning any error that occurred while persisting - * [`ChannelManager`]. - * - * # Panics - * - * This function panics if the background thread has panicked such as while persisting or - * handling events. + * A Lightning payment using BOLT 11. * - * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneIOErrorZ BackgroundProcessor_join(struct LDKBackgroundProcessor this_arg); +void LSPS1PaymentInfo_set_bolt11(struct LDKLSPS1PaymentInfo *NONNULL_PTR this_ptr, struct LDKLSPS1Bolt11PaymentInfo val); /** - * Stop `BackgroundProcessor`'s thread, returning any error that occurred while persisting - * [`ChannelManager`]. + * An onchain payment. * - * # Panics + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKLSPS1OnchainPaymentInfo LSPS1PaymentInfo_get_onchain(const struct LDKLSPS1PaymentInfo *NONNULL_PTR this_ptr); + +/** + * An onchain payment. * - * This function panics if the background thread has panicked such as while persisting or - * handling events. + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void LSPS1PaymentInfo_set_onchain(struct LDKLSPS1PaymentInfo *NONNULL_PTR this_ptr, struct LDKLSPS1OnchainPaymentInfo val); + +/** + * Constructs a new LSPS1PaymentInfo given each field * - * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager + * Note that bolt11_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that onchain_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneIOErrorZ BackgroundProcessor_stop(struct LDKBackgroundProcessor this_arg); +MUST_USE_RES struct LDKLSPS1PaymentInfo LSPS1PaymentInfo_new(struct LDKLSPS1Bolt11PaymentInfo bolt11_arg, struct LDKLSPS1OnchainPaymentInfo onchain_arg); /** - * Frees any resources used by the Bolt11ParseError, if is_owned is set and inner is non-NULL. + * Creates a copy of the LSPS1PaymentInfo */ -void Bolt11ParseError_free(struct LDKBolt11ParseError this_obj); +struct LDKLSPS1PaymentInfo LSPS1PaymentInfo_clone(const struct LDKLSPS1PaymentInfo *NONNULL_PTR orig); /** - * Checks if two Bolt11ParseErrors contain equal inner contents. + * Checks if two LSPS1PaymentInfos contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool Bolt11ParseError_eq(const struct LDKBolt11ParseError *NONNULL_PTR a, const struct LDKBolt11ParseError *NONNULL_PTR b); +bool LSPS1PaymentInfo_eq(const struct LDKLSPS1PaymentInfo *NONNULL_PTR a, const struct LDKLSPS1PaymentInfo *NONNULL_PTR b); /** - * Creates a copy of the Bolt11ParseError + * Frees any resources used by the LSPS1Bolt11PaymentInfo, if is_owned is set and inner is non-NULL. */ -struct LDKBolt11ParseError Bolt11ParseError_clone(const struct LDKBolt11ParseError *NONNULL_PTR orig); +void LSPS1Bolt11PaymentInfo_free(struct LDKLSPS1Bolt11PaymentInfo this_obj); /** - * Frees any resources used by the ParseOrSemanticError + * Indicates the current state of the payment. */ -void ParseOrSemanticError_free(struct LDKParseOrSemanticError this_ptr); +enum LDKLSPS1PaymentState LSPS1Bolt11PaymentInfo_get_state(const struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR this_ptr); /** - * Creates a copy of the ParseOrSemanticError + * Indicates the current state of the payment. */ -struct LDKParseOrSemanticError ParseOrSemanticError_clone(const struct LDKParseOrSemanticError *NONNULL_PTR orig); +void LSPS1Bolt11PaymentInfo_set_state(struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR this_ptr, enum LDKLSPS1PaymentState val); /** - * Utility method to constructs a new ParseError-variant ParseOrSemanticError + * The datetime when the payment option expires. */ -struct LDKParseOrSemanticError ParseOrSemanticError_parse_error(struct LDKBolt11ParseError a); +struct LDKLSPSDateTime LSPS1Bolt11PaymentInfo_get_expires_at(const struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new SemanticError-variant ParseOrSemanticError + * The datetime when the payment option expires. */ -struct LDKParseOrSemanticError ParseOrSemanticError_semantic_error(enum LDKBolt11SemanticError a); +void LSPS1Bolt11PaymentInfo_set_expires_at(struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR this_ptr, struct LDKLSPSDateTime val); /** - * Checks if two ParseOrSemanticErrors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * The total fee the LSP will charge to open this channel in satoshi. */ -bool ParseOrSemanticError_eq(const struct LDKParseOrSemanticError *NONNULL_PTR a, const struct LDKParseOrSemanticError *NONNULL_PTR b); +uint64_t LSPS1Bolt11PaymentInfo_get_fee_total_sat(const struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Bolt11Invoice, if is_owned is set and inner is non-NULL. + * The total fee the LSP will charge to open this channel in satoshi. */ -void Bolt11Invoice_free(struct LDKBolt11Invoice this_obj); +void LSPS1Bolt11PaymentInfo_set_fee_total_sat(struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if two Bolt11Invoices contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The amount the client needs to pay to have the requested channel openend. */ -bool Bolt11Invoice_eq(const struct LDKBolt11Invoice *NONNULL_PTR a, const struct LDKBolt11Invoice *NONNULL_PTR b); +uint64_t LSPS1Bolt11PaymentInfo_get_order_total_sat(const struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR this_ptr); /** - * Creates a copy of the Bolt11Invoice + * The amount the client needs to pay to have the requested channel openend. */ -struct LDKBolt11Invoice Bolt11Invoice_clone(const struct LDKBolt11Invoice *NONNULL_PTR orig); +void LSPS1Bolt11PaymentInfo_set_order_total_sat(struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Generates a non-cryptographic 64-bit hash of the Bolt11Invoice. + * A BOLT11 invoice the client can pay to have to channel opened. */ -uint64_t Bolt11Invoice_hash(const struct LDKBolt11Invoice *NONNULL_PTR o); +struct LDKBolt11Invoice LSPS1Bolt11PaymentInfo_get_invoice(const struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Bolt11InvoiceDescription + * A BOLT11 invoice the client can pay to have to channel opened. */ -void Bolt11InvoiceDescription_free(struct LDKBolt11InvoiceDescription this_ptr); +void LSPS1Bolt11PaymentInfo_set_invoice(struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR this_ptr, struct LDKBolt11Invoice val); /** - * Creates a copy of the Bolt11InvoiceDescription + * Constructs a new LSPS1Bolt11PaymentInfo given each field */ -struct LDKBolt11InvoiceDescription Bolt11InvoiceDescription_clone(const struct LDKBolt11InvoiceDescription *NONNULL_PTR orig); +MUST_USE_RES struct LDKLSPS1Bolt11PaymentInfo LSPS1Bolt11PaymentInfo_new(enum LDKLSPS1PaymentState state_arg, struct LDKLSPSDateTime expires_at_arg, uint64_t fee_total_sat_arg, uint64_t order_total_sat_arg, struct LDKBolt11Invoice invoice_arg); /** - * Utility method to constructs a new Direct-variant Bolt11InvoiceDescription + * Creates a copy of the LSPS1Bolt11PaymentInfo */ -struct LDKBolt11InvoiceDescription Bolt11InvoiceDescription_direct(struct LDKDescription a); +struct LDKLSPS1Bolt11PaymentInfo LSPS1Bolt11PaymentInfo_clone(const struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR orig); /** - * Utility method to constructs a new Hash-variant Bolt11InvoiceDescription + * Checks if two LSPS1Bolt11PaymentInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKBolt11InvoiceDescription Bolt11InvoiceDescription_hash(struct LDKSha256 a); +bool LSPS1Bolt11PaymentInfo_eq(const struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR a, const struct LDKLSPS1Bolt11PaymentInfo *NONNULL_PTR b); /** - * Checks if two Bolt11InvoiceDescriptions contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Frees any resources used by the LSPS1OnchainPaymentInfo, if is_owned is set and inner is non-NULL. */ -bool Bolt11InvoiceDescription_eq(const struct LDKBolt11InvoiceDescription *NONNULL_PTR a, const struct LDKBolt11InvoiceDescription *NONNULL_PTR b); +void LSPS1OnchainPaymentInfo_free(struct LDKLSPS1OnchainPaymentInfo this_obj); /** - * Get the string representation of a Bolt11InvoiceDescription object + * Indicates the current state of the payment. */ -struct LDKStr Bolt11InvoiceDescription_to_str(const struct LDKBolt11InvoiceDescription *NONNULL_PTR o); +enum LDKLSPS1PaymentState LSPS1OnchainPaymentInfo_get_state(const struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the SignedRawBolt11Invoice, if is_owned is set and inner is non-NULL. + * Indicates the current state of the payment. */ -void SignedRawBolt11Invoice_free(struct LDKSignedRawBolt11Invoice this_obj); +void LSPS1OnchainPaymentInfo_set_state(struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr, enum LDKLSPS1PaymentState val); /** - * Checks if two SignedRawBolt11Invoices contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The datetime when the payment option expires. */ -bool SignedRawBolt11Invoice_eq(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR a, const struct LDKSignedRawBolt11Invoice *NONNULL_PTR b); +struct LDKLSPSDateTime LSPS1OnchainPaymentInfo_get_expires_at(const struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr); /** - * Creates a copy of the SignedRawBolt11Invoice + * The datetime when the payment option expires. */ -struct LDKSignedRawBolt11Invoice SignedRawBolt11Invoice_clone(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR orig); +void LSPS1OnchainPaymentInfo_set_expires_at(struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr, struct LDKLSPSDateTime val); /** - * Generates a non-cryptographic 64-bit hash of the SignedRawBolt11Invoice. + * The total fee the LSP will charge to open this channel in satoshi. */ -uint64_t SignedRawBolt11Invoice_hash(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR o); +uint64_t LSPS1OnchainPaymentInfo_get_fee_total_sat(const struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the RawBolt11Invoice, if is_owned is set and inner is non-NULL. + * The total fee the LSP will charge to open this channel in satoshi. */ -void RawBolt11Invoice_free(struct LDKRawBolt11Invoice this_obj); +void LSPS1OnchainPaymentInfo_set_fee_total_sat(struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * data part + * The amount the client needs to pay to have the requested channel openend. + */ +uint64_t LSPS1OnchainPaymentInfo_get_order_total_sat(const struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr); + +/** + * The amount the client needs to pay to have the requested channel openend. */ -struct LDKRawDataPart RawBolt11Invoice_get_data(const struct LDKRawBolt11Invoice *NONNULL_PTR this_ptr); +void LSPS1OnchainPaymentInfo_set_order_total_sat(struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * data part + * An on-chain address the client can send [`Self::order_total_sat`] to to have the channel + * opened. */ -void RawBolt11Invoice_set_data(struct LDKRawBolt11Invoice *NONNULL_PTR this_ptr, struct LDKRawDataPart val); +struct LDKAddress LSPS1OnchainPaymentInfo_get_address(const struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr); /** - * Checks if two RawBolt11Invoices contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * An on-chain address the client can send [`Self::order_total_sat`] to to have the channel + * opened. */ -bool RawBolt11Invoice_eq(const struct LDKRawBolt11Invoice *NONNULL_PTR a, const struct LDKRawBolt11Invoice *NONNULL_PTR b); +void LSPS1OnchainPaymentInfo_set_address(struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr, struct LDKAddress val); /** - * Creates a copy of the RawBolt11Invoice + * The minimum number of block confirmations that are required for the on-chain payment to be + * considered confirmed. */ -struct LDKRawBolt11Invoice RawBolt11Invoice_clone(const struct LDKRawBolt11Invoice *NONNULL_PTR orig); +struct LDKCOption_u16Z LSPS1OnchainPaymentInfo_get_min_onchain_payment_confirmations(const struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the RawBolt11Invoice. + * The minimum number of block confirmations that are required for the on-chain payment to be + * considered confirmed. */ -uint64_t RawBolt11Invoice_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR o); +void LSPS1OnchainPaymentInfo_set_min_onchain_payment_confirmations(struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); /** - * Frees any resources used by the RawDataPart, if is_owned is set and inner is non-NULL. + * The address where the LSP will send the funds if the order fails. */ -void RawDataPart_free(struct LDKRawDataPart this_obj); +struct LDKCOption_AddressZ LSPS1OnchainPaymentInfo_get_refund_onchain_address(const struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr); /** - * generation time of the invoice + * The address where the LSP will send the funds if the order fails. */ -struct LDKPositiveTimestamp RawDataPart_get_timestamp(const struct LDKRawDataPart *NONNULL_PTR this_ptr); +void LSPS1OnchainPaymentInfo_set_refund_onchain_address(struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR this_ptr, struct LDKCOption_AddressZ val); /** - * generation time of the invoice + * Creates a copy of the LSPS1OnchainPaymentInfo */ -void RawDataPart_set_timestamp(struct LDKRawDataPart *NONNULL_PTR this_ptr, struct LDKPositiveTimestamp val); +struct LDKLSPS1OnchainPaymentInfo LSPS1OnchainPaymentInfo_clone(const struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR orig); /** - * Checks if two RawDataParts contain equal inner contents. + * Checks if two LSPS1OnchainPaymentInfos contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool RawDataPart_eq(const struct LDKRawDataPart *NONNULL_PTR a, const struct LDKRawDataPart *NONNULL_PTR b); +bool LSPS1OnchainPaymentInfo_eq(const struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR a, const struct LDKLSPS1OnchainPaymentInfo *NONNULL_PTR b); /** - * Creates a copy of the RawDataPart + * Creates a copy of the LSPS1PaymentState */ -struct LDKRawDataPart RawDataPart_clone(const struct LDKRawDataPart *NONNULL_PTR orig); +enum LDKLSPS1PaymentState LSPS1PaymentState_clone(const enum LDKLSPS1PaymentState *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the RawDataPart. + * Utility method to constructs a new ExpectPayment-variant LSPS1PaymentState */ -uint64_t RawDataPart_hash(const struct LDKRawDataPart *NONNULL_PTR o); +enum LDKLSPS1PaymentState LSPS1PaymentState_expect_payment(void); /** - * Frees any resources used by the PositiveTimestamp, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Paid-variant LSPS1PaymentState */ -void PositiveTimestamp_free(struct LDKPositiveTimestamp this_obj); +enum LDKLSPS1PaymentState LSPS1PaymentState_paid(void); /** - * Checks if two PositiveTimestamps contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new Refunded-variant LSPS1PaymentState */ -bool PositiveTimestamp_eq(const struct LDKPositiveTimestamp *NONNULL_PTR a, const struct LDKPositiveTimestamp *NONNULL_PTR b); +enum LDKLSPS1PaymentState LSPS1PaymentState_refunded(void); /** - * Creates a copy of the PositiveTimestamp + * Checks if two LSPS1PaymentStates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKPositiveTimestamp PositiveTimestamp_clone(const struct LDKPositiveTimestamp *NONNULL_PTR orig); +bool LSPS1PaymentState_eq(const enum LDKLSPS1PaymentState *NONNULL_PTR a, const enum LDKLSPS1PaymentState *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the PositiveTimestamp. + * Frees any resources used by the LSPS1OnchainPayment, if is_owned is set and inner is non-NULL. */ -uint64_t PositiveTimestamp_hash(const struct LDKPositiveTimestamp *NONNULL_PTR o); +void LSPS1OnchainPayment_free(struct LDKLSPS1OnchainPayment this_obj); /** - * Creates a copy of the SiPrefix + * The outpoint of the payment. */ -enum LDKSiPrefix SiPrefix_clone(const enum LDKSiPrefix *NONNULL_PTR orig); +struct LDKStr LSPS1OnchainPayment_get_outpoint(const struct LDKLSPS1OnchainPayment *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Milli-variant SiPrefix + * The outpoint of the payment. */ -enum LDKSiPrefix SiPrefix_milli(void); +void LSPS1OnchainPayment_set_outpoint(struct LDKLSPS1OnchainPayment *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Utility method to constructs a new Micro-variant SiPrefix + * The amount of satoshi paid. */ -enum LDKSiPrefix SiPrefix_micro(void); +uint64_t LSPS1OnchainPayment_get_sat(const struct LDKLSPS1OnchainPayment *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Nano-variant SiPrefix + * The amount of satoshi paid. */ -enum LDKSiPrefix SiPrefix_nano(void); +void LSPS1OnchainPayment_set_sat(struct LDKLSPS1OnchainPayment *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new Pico-variant SiPrefix + * Indicates if the LSP regards the transaction as sufficiently confirmed. */ -enum LDKSiPrefix SiPrefix_pico(void); +bool LSPS1OnchainPayment_get_confirmed(const struct LDKLSPS1OnchainPayment *NONNULL_PTR this_ptr); /** - * Checks if two SiPrefixs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Indicates if the LSP regards the transaction as sufficiently confirmed. */ -bool SiPrefix_eq(const enum LDKSiPrefix *NONNULL_PTR a, const enum LDKSiPrefix *NONNULL_PTR b); +void LSPS1OnchainPayment_set_confirmed(struct LDKLSPS1OnchainPayment *NONNULL_PTR this_ptr, bool val); /** - * Generates a non-cryptographic 64-bit hash of the SiPrefix. + * Constructs a new LSPS1OnchainPayment given each field */ -uint64_t SiPrefix_hash(const enum LDKSiPrefix *NONNULL_PTR o); +MUST_USE_RES struct LDKLSPS1OnchainPayment LSPS1OnchainPayment_new(struct LDKStr outpoint_arg, uint64_t sat_arg, bool confirmed_arg); /** - * Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix. - * This is effectively 10^12 * the prefix multiplier + * Creates a copy of the LSPS1OnchainPayment */ -MUST_USE_RES uint64_t SiPrefix_multiplier(const enum LDKSiPrefix *NONNULL_PTR this_arg); +struct LDKLSPS1OnchainPayment LSPS1OnchainPayment_clone(const struct LDKLSPS1OnchainPayment *NONNULL_PTR orig); /** - * Creates a copy of the Currency + * Checks if two LSPS1OnchainPayments contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -enum LDKCurrency Currency_clone(const enum LDKCurrency *NONNULL_PTR orig); +bool LSPS1OnchainPayment_eq(const struct LDKLSPS1OnchainPayment *NONNULL_PTR a, const struct LDKLSPS1OnchainPayment *NONNULL_PTR b); /** - * Utility method to constructs a new Bitcoin-variant Currency + * Frees any resources used by the LSPS1ChannelInfo, if is_owned is set and inner is non-NULL. */ -enum LDKCurrency Currency_bitcoin(void); +void LSPS1ChannelInfo_free(struct LDKLSPS1ChannelInfo this_obj); /** - * Utility method to constructs a new BitcoinTestnet-variant Currency + * The datetime when the funding transaction has been published. */ -enum LDKCurrency Currency_bitcoin_testnet(void); +struct LDKLSPSDateTime LSPS1ChannelInfo_get_funded_at(const struct LDKLSPS1ChannelInfo *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Regtest-variant Currency + * The datetime when the funding transaction has been published. */ -enum LDKCurrency Currency_regtest(void); +void LSPS1ChannelInfo_set_funded_at(struct LDKLSPS1ChannelInfo *NONNULL_PTR this_ptr, struct LDKLSPSDateTime val); /** - * Utility method to constructs a new Simnet-variant Currency + * The outpoint of the funding transaction. */ -enum LDKCurrency Currency_simnet(void); +struct LDKOutPoint LSPS1ChannelInfo_get_funding_outpoint(const struct LDKLSPS1ChannelInfo *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Signet-variant Currency + * The outpoint of the funding transaction. */ -enum LDKCurrency Currency_signet(void); +void LSPS1ChannelInfo_set_funding_outpoint(struct LDKLSPS1ChannelInfo *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Generates a non-cryptographic 64-bit hash of the Currency. + * The earliest datetime when the channel may be closed by the LSP. */ -uint64_t Currency_hash(const enum LDKCurrency *NONNULL_PTR o); +struct LDKLSPSDateTime LSPS1ChannelInfo_get_expires_at(const struct LDKLSPS1ChannelInfo *NONNULL_PTR this_ptr); /** - * Checks if two Currencys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * The earliest datetime when the channel may be closed by the LSP. */ -bool Currency_eq(const enum LDKCurrency *NONNULL_PTR a, const enum LDKCurrency *NONNULL_PTR b); +void LSPS1ChannelInfo_set_expires_at(struct LDKLSPS1ChannelInfo *NONNULL_PTR this_ptr, struct LDKLSPSDateTime val); /** - * Frees any resources used by the Sha256, if is_owned is set and inner is non-NULL. + * Constructs a new LSPS1ChannelInfo given each field */ -void Sha256_free(struct LDKSha256 this_obj); +MUST_USE_RES struct LDKLSPS1ChannelInfo LSPS1ChannelInfo_new(struct LDKLSPSDateTime funded_at_arg, struct LDKOutPoint funding_outpoint_arg, struct LDKLSPSDateTime expires_at_arg); /** - * Creates a copy of the Sha256 + * Creates a copy of the LSPS1ChannelInfo */ -struct LDKSha256 Sha256_clone(const struct LDKSha256 *NONNULL_PTR orig); +struct LDKLSPS1ChannelInfo LSPS1ChannelInfo_clone(const struct LDKLSPS1ChannelInfo *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the Sha256. + * Checks if two LSPS1ChannelInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint64_t Sha256_hash(const struct LDKSha256 *NONNULL_PTR o); +bool LSPS1ChannelInfo_eq(const struct LDKLSPS1ChannelInfo *NONNULL_PTR a, const struct LDKLSPS1ChannelInfo *NONNULL_PTR b); /** - * Checks if two Sha256s contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Frees any resources used by the LSPS1GetOrderRequest, if is_owned is set and inner is non-NULL. */ -bool Sha256_eq(const struct LDKSha256 *NONNULL_PTR a, const struct LDKSha256 *NONNULL_PTR b); +void LSPS1GetOrderRequest_free(struct LDKLSPS1GetOrderRequest this_obj); /** - * Constructs a new [`Sha256`] from the given bytes, which are assumed to be the output of a - * single sha256 hash. + * The id of the order. */ -MUST_USE_RES struct LDKSha256 Sha256_from_bytes(const uint8_t (*bytes)[32]); +struct LDKLSPS1OrderId LSPS1GetOrderRequest_get_order_id(const struct LDKLSPS1GetOrderRequest *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Description, if is_owned is set and inner is non-NULL. + * The id of the order. */ -void Description_free(struct LDKDescription this_obj); +void LSPS1GetOrderRequest_set_order_id(struct LDKLSPS1GetOrderRequest *NONNULL_PTR this_ptr, struct LDKLSPS1OrderId val); /** - * Creates a copy of the Description + * Constructs a new LSPS1GetOrderRequest given each field */ -struct LDKDescription Description_clone(const struct LDKDescription *NONNULL_PTR orig); +MUST_USE_RES struct LDKLSPS1GetOrderRequest LSPS1GetOrderRequest_new(struct LDKLSPS1OrderId order_id_arg); /** - * Generates a non-cryptographic 64-bit hash of the Description. + * Creates a copy of the LSPS1GetOrderRequest */ -uint64_t Description_hash(const struct LDKDescription *NONNULL_PTR o); +struct LDKLSPS1GetOrderRequest LSPS1GetOrderRequest_clone(const struct LDKLSPS1GetOrderRequest *NONNULL_PTR orig); /** - * Checks if two Descriptions contain equal inner contents. + * Checks if two LSPS1GetOrderRequests contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool Description_eq(const struct LDKDescription *NONNULL_PTR a, const struct LDKDescription *NONNULL_PTR b); +bool LSPS1GetOrderRequest_eq(const struct LDKLSPS1GetOrderRequest *NONNULL_PTR a, const struct LDKLSPS1GetOrderRequest *NONNULL_PTR b); /** - * Frees any resources used by the PayeePubKey, if is_owned is set and inner is non-NULL. + * Frees any resources used by the LSPS1Request */ -void PayeePubKey_free(struct LDKPayeePubKey this_obj); +void LSPS1Request_free(struct LDKLSPS1Request this_ptr); -struct LDKPublicKey PayeePubKey_get_a(const struct LDKPayeePubKey *NONNULL_PTR this_ptr); - -void PayeePubKey_set_a(struct LDKPayeePubKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Creates a copy of the LSPS1Request + */ +struct LDKLSPS1Request LSPS1Request_clone(const struct LDKLSPS1Request *NONNULL_PTR orig); /** - * Constructs a new PayeePubKey given each field + * Utility method to constructs a new GetInfo-variant LSPS1Request */ -MUST_USE_RES struct LDKPayeePubKey PayeePubKey_new(struct LDKPublicKey a_arg); +struct LDKLSPS1Request LSPS1Request_get_info(struct LDKLSPS1GetInfoRequest a); /** - * Creates a copy of the PayeePubKey + * Utility method to constructs a new CreateOrder-variant LSPS1Request */ -struct LDKPayeePubKey PayeePubKey_clone(const struct LDKPayeePubKey *NONNULL_PTR orig); +struct LDKLSPS1Request LSPS1Request_create_order(struct LDKLSPS1CreateOrderRequest a); /** - * Generates a non-cryptographic 64-bit hash of the PayeePubKey. + * Utility method to constructs a new GetOrder-variant LSPS1Request */ -uint64_t PayeePubKey_hash(const struct LDKPayeePubKey *NONNULL_PTR o); +struct LDKLSPS1Request LSPS1Request_get_order(struct LDKLSPS1GetOrderRequest a); /** - * Checks if two PayeePubKeys contain equal inner contents. + * Checks if two LSPS1Requests contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. */ -bool PayeePubKey_eq(const struct LDKPayeePubKey *NONNULL_PTR a, const struct LDKPayeePubKey *NONNULL_PTR b); +bool LSPS1Request_eq(const struct LDKLSPS1Request *NONNULL_PTR a, const struct LDKLSPS1Request *NONNULL_PTR b); /** - * Frees any resources used by the ExpiryTime, if is_owned is set and inner is non-NULL. + * Frees any resources used by the LSPS1Response */ -void ExpiryTime_free(struct LDKExpiryTime this_obj); +void LSPS1Response_free(struct LDKLSPS1Response this_ptr); /** - * Creates a copy of the ExpiryTime + * Creates a copy of the LSPS1Response */ -struct LDKExpiryTime ExpiryTime_clone(const struct LDKExpiryTime *NONNULL_PTR orig); +struct LDKLSPS1Response LSPS1Response_clone(const struct LDKLSPS1Response *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the ExpiryTime. + * Utility method to constructs a new GetInfo-variant LSPS1Response */ -uint64_t ExpiryTime_hash(const struct LDKExpiryTime *NONNULL_PTR o); +struct LDKLSPS1Response LSPS1Response_get_info(struct LDKLSPS1GetInfoResponse a); /** - * Checks if two ExpiryTimes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new GetInfoError-variant LSPS1Response */ -bool ExpiryTime_eq(const struct LDKExpiryTime *NONNULL_PTR a, const struct LDKExpiryTime *NONNULL_PTR b); +struct LDKLSPS1Response LSPS1Response_get_info_error(struct LDKLSPSResponseError a); /** - * Frees any resources used by the MinFinalCltvExpiryDelta, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new CreateOrder-variant LSPS1Response */ -void MinFinalCltvExpiryDelta_free(struct LDKMinFinalCltvExpiryDelta this_obj); - -uint64_t MinFinalCltvExpiryDelta_get_a(const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR this_ptr); - -void MinFinalCltvExpiryDelta_set_a(struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR this_ptr, uint64_t val); +struct LDKLSPS1Response LSPS1Response_create_order(struct LDKLSPS1CreateOrderResponse a); /** - * Constructs a new MinFinalCltvExpiryDelta given each field + * Utility method to constructs a new CreateOrderError-variant LSPS1Response */ -MUST_USE_RES struct LDKMinFinalCltvExpiryDelta MinFinalCltvExpiryDelta_new(uint64_t a_arg); +struct LDKLSPS1Response LSPS1Response_create_order_error(struct LDKLSPSResponseError a); /** - * Creates a copy of the MinFinalCltvExpiryDelta + * Utility method to constructs a new GetOrder-variant LSPS1Response */ -struct LDKMinFinalCltvExpiryDelta MinFinalCltvExpiryDelta_clone(const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR orig); +struct LDKLSPS1Response LSPS1Response_get_order(struct LDKLSPS1CreateOrderResponse a); /** - * Generates a non-cryptographic 64-bit hash of the MinFinalCltvExpiryDelta. + * Utility method to constructs a new GetOrderError-variant LSPS1Response */ -uint64_t MinFinalCltvExpiryDelta_hash(const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR o); +struct LDKLSPS1Response LSPS1Response_get_order_error(struct LDKLSPSResponseError a); /** - * Checks if two MinFinalCltvExpiryDeltas contain equal inner contents. + * Checks if two LSPS1Responses contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. */ -bool MinFinalCltvExpiryDelta_eq(const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR a, const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR b); +bool LSPS1Response_eq(const struct LDKLSPS1Response *NONNULL_PTR a, const struct LDKLSPS1Response *NONNULL_PTR b); /** - * Frees any resources used by the Fallback + * Frees any resources used by the LSPS1Message */ -void Fallback_free(struct LDKFallback this_ptr); +void LSPS1Message_free(struct LDKLSPS1Message this_ptr); /** - * Creates a copy of the Fallback + * Creates a copy of the LSPS1Message */ -struct LDKFallback Fallback_clone(const struct LDKFallback *NONNULL_PTR orig); +struct LDKLSPS1Message LSPS1Message_clone(const struct LDKLSPS1Message *NONNULL_PTR orig); /** - * Utility method to constructs a new SegWitProgram-variant Fallback + * Utility method to constructs a new Request-variant LSPS1Message */ -struct LDKFallback Fallback_seg_wit_program(struct LDKWitnessVersion version, struct LDKCVec_u8Z program); +struct LDKLSPS1Message LSPS1Message_request(struct LDKLSPSRequestId a, struct LDKLSPS1Request b); /** - * Utility method to constructs a new PubKeyHash-variant Fallback + * Utility method to constructs a new Response-variant LSPS1Message */ -struct LDKFallback Fallback_pub_key_hash(struct LDKTwentyBytes a); +struct LDKLSPS1Message LSPS1Message_response(struct LDKLSPSRequestId a, struct LDKLSPS1Response b); /** - * Utility method to constructs a new ScriptHash-variant Fallback + * Checks if two LSPS1Messages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKFallback Fallback_script_hash(struct LDKTwentyBytes a); +bool LSPS1Message_eq(const struct LDKLSPS1Message *NONNULL_PTR a, const struct LDKLSPS1Message *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the Fallback. + * Frees any resources used by the LSPS2ClientConfig, if is_owned is set and inner is non-NULL. */ -uint64_t Fallback_hash(const struct LDKFallback *NONNULL_PTR o); +void LSPS2ClientConfig_free(struct LDKLSPS2ClientConfig this_obj); /** - * Checks if two Fallbacks contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Constructs a new LSPS2ClientConfig given each field */ -bool Fallback_eq(const struct LDKFallback *NONNULL_PTR a, const struct LDKFallback *NONNULL_PTR b); +MUST_USE_RES struct LDKLSPS2ClientConfig LSPS2ClientConfig_new(void); /** - * Frees any resources used by the Bolt11InvoiceSignature, if is_owned is set and inner is non-NULL. + * Creates a copy of the LSPS2ClientConfig */ -void Bolt11InvoiceSignature_free(struct LDKBolt11InvoiceSignature this_obj); - -struct LDKRecoverableSignature Bolt11InvoiceSignature_get_a(const struct LDKBolt11InvoiceSignature *NONNULL_PTR this_ptr); - -void Bolt11InvoiceSignature_set_a(struct LDKBolt11InvoiceSignature *NONNULL_PTR this_ptr, struct LDKRecoverableSignature val); +struct LDKLSPS2ClientConfig LSPS2ClientConfig_clone(const struct LDKLSPS2ClientConfig *NONNULL_PTR orig); /** - * Constructs a new Bolt11InvoiceSignature given each field + * Frees any resources used by the LSPS2ClientHandler, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKBolt11InvoiceSignature Bolt11InvoiceSignature_new(struct LDKRecoverableSignature a_arg); +void LSPS2ClientHandler_free(struct LDKLSPS2ClientHandler this_obj); /** - * Creates a copy of the Bolt11InvoiceSignature + * Request the channel opening parameters from the LSP. + * + * This initiates the JIT-channel flow that, at the end of it, will have the LSP + * open a channel with sufficient inbound liquidity to be able to receive the payment. + * + * The user will receive the LSP's response via an [`OpeningParametersReady`] event. + * + * `counterparty_node_id` is the `node_id` of the LSP you would like to use. + * + * `token` is an optional `String` that will be provided to the LSP. + * It can be used by the LSP as an API key, coupon code, or some other way to identify a user. + * + * Returns the used [`LSPSRequestId`], which will be returned via [`OpeningParametersReady`]. + * + * [`OpeningParametersReady`]: crate::lsps2::event::LSPS2ClientEvent::OpeningParametersReady */ -struct LDKBolt11InvoiceSignature Bolt11InvoiceSignature_clone(const struct LDKBolt11InvoiceSignature *NONNULL_PTR orig); +MUST_USE_RES struct LDKLSPSRequestId LSPS2ClientHandler_request_opening_params(const struct LDKLSPS2ClientHandler *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKCOption_StrZ token); /** - * Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceSignature. + * Confirms a set of chosen channel opening parameters to use for the JIT channel and + * requests the necessary invoice generation parameters from the LSP. + * + * Should be called in response to receiving a [`OpeningParametersReady`] event. + * + * The user will receive the LSP's response via an [`InvoiceParametersReady`] event. + * + * If `payment_size_msat` is [`Option::Some`] then the invoice will be for a fixed amount + * and MPP can be used to pay it. + * + * If `payment_size_msat` is [`Option::None`] then the invoice can be for an arbitrary amount + * but MPP can no longer be used to pay it. + * + * The client agrees to paying an opening fee equal to + * `max(min_fee_msat, proportional*(payment_size_msat/1_000_000))`. + * + * [`OpeningParametersReady`]: crate::lsps2::event::LSPS2ClientEvent::OpeningParametersReady + * [`InvoiceParametersReady`]: crate::lsps2::event::LSPS2ClientEvent::InvoiceParametersReady */ -uint64_t Bolt11InvoiceSignature_hash(const struct LDKBolt11InvoiceSignature *NONNULL_PTR o); +MUST_USE_RES struct LDKCResult_LSPSRequestIdAPIErrorZ LSPS2ClientHandler_select_opening_params(const struct LDKLSPS2ClientHandler *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKCOption_u64Z payment_size_msat, struct LDKLSPS2OpeningFeeParams opening_fee_params); /** - * Checks if two Bolt11InvoiceSignatures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Frees any resources used by the LSPS2ClientEvent */ -bool Bolt11InvoiceSignature_eq(const struct LDKBolt11InvoiceSignature *NONNULL_PTR a, const struct LDKBolt11InvoiceSignature *NONNULL_PTR b); +void LSPS2ClientEvent_free(struct LDKLSPS2ClientEvent this_ptr); /** - * Frees any resources used by the PrivateRoute, if is_owned is set and inner is non-NULL. + * Creates a copy of the LSPS2ClientEvent */ -void PrivateRoute_free(struct LDKPrivateRoute this_obj); +struct LDKLSPS2ClientEvent LSPS2ClientEvent_clone(const struct LDKLSPS2ClientEvent *NONNULL_PTR orig); /** - * Creates a copy of the PrivateRoute + * Utility method to constructs a new OpeningParametersReady-variant LSPS2ClientEvent */ -struct LDKPrivateRoute PrivateRoute_clone(const struct LDKPrivateRoute *NONNULL_PTR orig); +struct LDKLSPS2ClientEvent LSPS2ClientEvent_opening_parameters_ready(struct LDKLSPSRequestId request_id, struct LDKPublicKey counterparty_node_id, struct LDKCVec_LSPS2OpeningFeeParamsZ opening_fee_params_menu); /** - * Generates a non-cryptographic 64-bit hash of the PrivateRoute. + * Utility method to constructs a new InvoiceParametersReady-variant LSPS2ClientEvent */ -uint64_t PrivateRoute_hash(const struct LDKPrivateRoute *NONNULL_PTR o); +struct LDKLSPS2ClientEvent LSPS2ClientEvent_invoice_parameters_ready(struct LDKLSPSRequestId request_id, struct LDKPublicKey counterparty_node_id, uint64_t intercept_scid, uint32_t cltv_expiry_delta, struct LDKCOption_u64Z payment_size_msat); /** - * Checks if two PrivateRoutes contain equal inner contents. + * Checks if two LSPS2ClientEvents contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. */ -bool PrivateRoute_eq(const struct LDKPrivateRoute *NONNULL_PTR a, const struct LDKPrivateRoute *NONNULL_PTR b); +bool LSPS2ClientEvent_eq(const struct LDKLSPS2ClientEvent *NONNULL_PTR a, const struct LDKLSPS2ClientEvent *NONNULL_PTR b); /** - * Disassembles the `SignedRawBolt11Invoice` into its three parts: - * 1. raw invoice - * 2. hash of the raw invoice - * 3. signature + * Frees any resources used by the LSPS2ServiceEvent */ -MUST_USE_RES struct LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ SignedRawBolt11Invoice_into_parts(struct LDKSignedRawBolt11Invoice this_arg); +void LSPS2ServiceEvent_free(struct LDKLSPS2ServiceEvent this_ptr); /** - * The [`RawBolt11Invoice`] which was signed. + * Creates a copy of the LSPS2ServiceEvent */ -MUST_USE_RES struct LDKRawBolt11Invoice SignedRawBolt11Invoice_raw_invoice(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); +struct LDKLSPS2ServiceEvent LSPS2ServiceEvent_clone(const struct LDKLSPS2ServiceEvent *NONNULL_PTR orig); /** - * The hash of the [`RawBolt11Invoice`] that was signed. + * Utility method to constructs a new GetInfo-variant LSPS2ServiceEvent */ -MUST_USE_RES const uint8_t (*SignedRawBolt11Invoice_signable_hash(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg))[32]; +struct LDKLSPS2ServiceEvent LSPS2ServiceEvent_get_info(struct LDKLSPSRequestId request_id, struct LDKPublicKey counterparty_node_id, struct LDKCOption_StrZ token); /** - * Signature for the invoice. + * Utility method to constructs a new BuyRequest-variant LSPS2ServiceEvent */ -MUST_USE_RES struct LDKBolt11InvoiceSignature SignedRawBolt11Invoice_signature(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); +struct LDKLSPS2ServiceEvent LSPS2ServiceEvent_buy_request(struct LDKLSPSRequestId request_id, struct LDKPublicKey counterparty_node_id, struct LDKLSPS2OpeningFeeParams opening_fee_params, struct LDKCOption_u64Z payment_size_msat); /** - * Recovers the public key used for signing the invoice from the recoverable signature. + * Utility method to constructs a new OpenChannel-variant LSPS2ServiceEvent */ -MUST_USE_RES struct LDKCResult_PayeePubKeySecp256k1ErrorZ SignedRawBolt11Invoice_recover_payee_pub_key(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); +struct LDKLSPS2ServiceEvent LSPS2ServiceEvent_open_channel(struct LDKPublicKey their_network_key, uint64_t amt_to_forward_msat, uint64_t opening_fee_msat, struct LDKU128 user_channel_id, uint64_t intercept_scid); /** - * Checks if the signature is valid for the included payee public key or if none exists if it's - * valid for the recovered signature (which should always be true?). + * Checks if two LSPS2ServiceEvents contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES bool SignedRawBolt11Invoice_check_signature(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); +bool LSPS2ServiceEvent_eq(const struct LDKLSPS2ServiceEvent *NONNULL_PTR a, const struct LDKLSPS2ServiceEvent *NONNULL_PTR b); /** - * Calculate the hash of the encoded `RawBolt11Invoice` which should be signed. + * Frees any resources used by the LSPS2GetInfoRequest, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKThirtyTwoBytes RawBolt11Invoice_signable_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2GetInfoRequest_free(struct LDKLSPS2GetInfoRequest this_obj); /** - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * An optional token to provide to the LSP. */ -MUST_USE_RES struct LDKSha256 RawBolt11Invoice_payment_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +struct LDKCOption_StrZ LSPS2GetInfoRequest_get_token(const struct LDKLSPS2GetInfoRequest *NONNULL_PTR this_ptr); /** - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * An optional token to provide to the LSP. */ -MUST_USE_RES struct LDKDescription RawBolt11Invoice_description(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2GetInfoRequest_set_token(struct LDKLSPS2GetInfoRequest *NONNULL_PTR this_ptr, struct LDKCOption_StrZ val); /** - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new LSPS2GetInfoRequest given each field */ -MUST_USE_RES struct LDKPayeePubKey RawBolt11Invoice_payee_pub_key(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPS2GetInfoRequest LSPS2GetInfoRequest_new(struct LDKCOption_StrZ token_arg); /** - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the LSPS2GetInfoRequest */ -MUST_USE_RES struct LDKSha256 RawBolt11Invoice_description_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +struct LDKLSPS2GetInfoRequest LSPS2GetInfoRequest_clone(const struct LDKLSPS2GetInfoRequest *NONNULL_PTR orig); /** - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two LSPS2GetInfoRequests contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKExpiryTime RawBolt11Invoice_expiry_time(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +bool LSPS2GetInfoRequest_eq(const struct LDKLSPS2GetInfoRequest *NONNULL_PTR a, const struct LDKLSPS2GetInfoRequest *NONNULL_PTR b); /** - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the LSPS2RawOpeningFeeParams, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKMinFinalCltvExpiryDelta RawBolt11Invoice_min_final_cltv_expiry_delta(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); - -MUST_USE_RES struct LDKCOption_ThirtyTwoBytesZ RawBolt11Invoice_payment_secret(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2RawOpeningFeeParams_free(struct LDKLSPS2RawOpeningFeeParams this_obj); -MUST_USE_RES struct LDKCOption_CVec_u8ZZ RawBolt11Invoice_payment_metadata(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +/** + * The minimum fee required for the channel open. + */ +uint64_t LSPS2RawOpeningFeeParams_get_min_fee_msat(const struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr); /** - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The minimum fee required for the channel open. */ -MUST_USE_RES struct LDKBolt11InvoiceFeatures RawBolt11Invoice_features(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2RawOpeningFeeParams_set_min_fee_msat(struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr, uint64_t val); -MUST_USE_RES struct LDKCVec_PrivateRouteZ RawBolt11Invoice_private_routes(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +/** + * A fee proportional to the size of the initial payment. + */ +uint32_t LSPS2RawOpeningFeeParams_get_proportional(const struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr); /** - * Returns `None` if no amount is set or on overflow. + * A fee proportional to the size of the initial payment. */ -MUST_USE_RES struct LDKCOption_u64Z RawBolt11Invoice_amount_pico_btc(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2RawOpeningFeeParams_set_proportional(struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr, uint32_t val); -MUST_USE_RES enum LDKCurrency RawBolt11Invoice_currency(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +/** + * An [`ISO8601`](https://www.iso.org/iso-8601-date-and-time-format.html) formatted date for which these params are valid. + */ +struct LDKLSPSDateTime LSPS2RawOpeningFeeParams_get_valid_until(const struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr); /** - * Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`. - * - * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. + * An [`ISO8601`](https://www.iso.org/iso-8601-date-and-time-format.html) formatted date for which these params are valid. */ -MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_unix_timestamp(uint64_t unix_seconds); +void LSPS2RawOpeningFeeParams_set_valid_until(struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr, struct LDKLSPSDateTime val); /** - * Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in - * the range `0..=MAX_TIMESTAMP`. - * - * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices. - * - * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. + * The number of blocks after confirmation that the LSP promises it will keep the channel alive without closing. */ -MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_system_time(uint64_t time); +uint32_t LSPS2RawOpeningFeeParams_get_min_lifetime(const struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr); /** - * Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range - * `0..=MAX_TIMESTAMP`. - * - * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices. - * - * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. + * The number of blocks after confirmation that the LSP promises it will keep the channel alive without closing. */ -MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_duration_since_epoch(uint64_t duration); +void LSPS2RawOpeningFeeParams_set_min_lifetime(struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr, uint32_t val); /** - * Returns the Unix timestamp representing the stored time + * The maximum number of blocks that the client is allowed to set its `to_self_delay` parameter. */ -MUST_USE_RES uint64_t PositiveTimestamp_as_unix_timestamp(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); +uint32_t LSPS2RawOpeningFeeParams_get_max_client_to_self_delay(const struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr); /** - * Returns the duration of the stored time since the Unix epoch + * The maximum number of blocks that the client is allowed to set its `to_self_delay` parameter. */ -MUST_USE_RES uint64_t PositiveTimestamp_as_duration_since_epoch(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); +void LSPS2RawOpeningFeeParams_set_max_client_to_self_delay(struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr, uint32_t val); /** - * Returns the [`SystemTime`] representing the stored time + * The minimum payment size that the LSP will accept when opening a channel. */ -MUST_USE_RES uint64_t PositiveTimestamp_as_time(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); +uint64_t LSPS2RawOpeningFeeParams_get_min_payment_size_msat(const struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr); /** - * The hash of the [`RawBolt11Invoice`] that was signed. + * The minimum payment size that the LSP will accept when opening a channel. */ -MUST_USE_RES struct LDKThirtyTwoBytes Bolt11Invoice_signable_hash(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2RawOpeningFeeParams_set_min_payment_size_msat(struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr, uint64_t val); /** - * Transform the `Bolt11Invoice` into its unchecked version. + * The maximum payment size that the LSP will accept when opening a channel. */ -MUST_USE_RES struct LDKSignedRawBolt11Invoice Bolt11Invoice_into_signed_raw(struct LDKBolt11Invoice this_arg); +uint64_t LSPS2RawOpeningFeeParams_get_max_payment_size_msat(const struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr); /** - * Check that the invoice is signed correctly and that key recovery works + * The maximum payment size that the LSP will accept when opening a channel. */ -MUST_USE_RES struct LDKCResult_NoneBolt11SemanticErrorZ Bolt11Invoice_check_signature(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2RawOpeningFeeParams_set_max_payment_size_msat(struct LDKLSPS2RawOpeningFeeParams *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a `Bolt11Invoice` from a [`SignedRawBolt11Invoice`] by checking all its invariants. - * ``` - * use lightning_invoice::*; - * - * let invoice = \"lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\\ - * h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\\ - * 5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\\ - * h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\\ - * j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\\ - * ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\\ - * guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\\ - * ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\\ - * p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\\ - * 8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\\ - * j5r6drg6k6zcqj0fcwg\"; - * - * let signed = invoice.parse::().unwrap(); - * - * assert!(Bolt11Invoice::from_signed(signed).is_ok()); - * ``` + * Constructs a new LSPS2RawOpeningFeeParams given each field */ -MUST_USE_RES struct LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ Bolt11Invoice_from_signed(struct LDKSignedRawBolt11Invoice signed_invoice); +MUST_USE_RES struct LDKLSPS2RawOpeningFeeParams LSPS2RawOpeningFeeParams_new(uint64_t min_fee_msat_arg, uint32_t proportional_arg, struct LDKLSPSDateTime valid_until_arg, uint32_t min_lifetime_arg, uint32_t max_client_to_self_delay_arg, uint64_t min_payment_size_msat_arg, uint64_t max_payment_size_msat_arg); /** - * Returns the `Bolt11Invoice`'s timestamp (should equal its creation time) + * Frees any resources used by the LSPS2OpeningFeeParams, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES uint64_t Bolt11Invoice_timestamp(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2OpeningFeeParams_free(struct LDKLSPS2OpeningFeeParams this_obj); /** - * Returns the `Bolt11Invoice`'s timestamp as a duration since the Unix epoch + * The minimum fee required for the channel open. */ -MUST_USE_RES uint64_t Bolt11Invoice_duration_since_epoch(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +uint64_t LSPS2OpeningFeeParams_get_min_fee_msat(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr); /** - * Returns the hash to which we will receive the preimage on completion of the payment + * The minimum fee required for the channel open. */ -MUST_USE_RES const uint8_t (*Bolt11Invoice_payment_hash(const struct LDKBolt11Invoice *NONNULL_PTR this_arg))[32]; +void LSPS2OpeningFeeParams_set_min_fee_msat(struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr, uint64_t val); /** - * Get the payee's public key if one was included in the invoice - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * A fee proportional to the size of the initial payment. */ -MUST_USE_RES struct LDKPublicKey Bolt11Invoice_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +uint32_t LSPS2OpeningFeeParams_get_proportional(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr); /** - * Get the payment secret if one was included in the invoice + * A fee proportional to the size of the initial payment. */ -MUST_USE_RES const uint8_t (*Bolt11Invoice_payment_secret(const struct LDKBolt11Invoice *NONNULL_PTR this_arg))[32]; +void LSPS2OpeningFeeParams_set_proportional(struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr, uint32_t val); /** - * Get the payment metadata blob if one was included in the invoice + * An [`ISO8601`](https://www.iso.org/iso-8601-date-and-time-format.html) formatted date for which these params are valid. */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ Bolt11Invoice_payment_metadata(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +struct LDKLSPSDateTime LSPS2OpeningFeeParams_get_valid_until(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr); /** - * Get the invoice features if they were included in the invoice - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * An [`ISO8601`](https://www.iso.org/iso-8601-date-and-time-format.html) formatted date for which these params are valid. */ -MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11Invoice_features(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2OpeningFeeParams_set_valid_until(struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr, struct LDKLSPSDateTime val); /** - * Recover the payee's public key (only to be used if none was included in the invoice) + * The number of blocks after confirmation that the LSP promises it will keep the channel alive without closing. */ -MUST_USE_RES struct LDKPublicKey Bolt11Invoice_recover_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +uint32_t LSPS2OpeningFeeParams_get_min_lifetime(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr); /** - * Recover the payee's public key if one was included in the invoice, otherwise return the - * recovered public key from the signature + * The number of blocks after confirmation that the LSP promises it will keep the channel alive without closing. */ -MUST_USE_RES struct LDKPublicKey Bolt11Invoice_get_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2OpeningFeeParams_set_min_lifetime(struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr, uint32_t val); /** - * Returns the Duration since the Unix epoch at which the invoice expires. - * Returning None if overflow occurred. + * The maximum number of blocks that the client is allowed to set its `to_self_delay` parameter. */ -MUST_USE_RES struct LDKCOption_u64Z Bolt11Invoice_expires_at(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +uint32_t LSPS2OpeningFeeParams_get_max_client_to_self_delay(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr); /** - * Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`]. + * The maximum number of blocks that the client is allowed to set its `to_self_delay` parameter. */ -MUST_USE_RES uint64_t Bolt11Invoice_expiry_time(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2OpeningFeeParams_set_max_client_to_self_delay(struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr, uint32_t val); /** - * Returns whether the invoice has expired. + * The minimum payment size that the LSP will accept when opening a channel. */ -MUST_USE_RES bool Bolt11Invoice_is_expired(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +uint64_t LSPS2OpeningFeeParams_get_min_payment_size_msat(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr); /** - * Returns the Duration remaining until the invoice expires. + * The minimum payment size that the LSP will accept when opening a channel. */ -MUST_USE_RES uint64_t Bolt11Invoice_duration_until_expiry(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2OpeningFeeParams_set_min_payment_size_msat(struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr, uint64_t val); /** - * Returns the Duration remaining until the invoice expires given the current time. - * `time` is the timestamp as a duration since the Unix epoch. + * The maximum payment size that the LSP will accept when opening a channel. */ -MUST_USE_RES uint64_t Bolt11Invoice_expiration_remaining_from_epoch(const struct LDKBolt11Invoice *NONNULL_PTR this_arg, uint64_t time); +uint64_t LSPS2OpeningFeeParams_get_max_payment_size_msat(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr); /** - * Returns whether the expiry time would pass at the given point in time. - * `at_time` is the timestamp as a duration since the Unix epoch. + * The maximum payment size that the LSP will accept when opening a channel. */ -MUST_USE_RES bool Bolt11Invoice_would_expire(const struct LDKBolt11Invoice *NONNULL_PTR this_arg, uint64_t at_time); +void LSPS2OpeningFeeParams_set_max_payment_size_msat(struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr, uint64_t val); /** - * Returns the invoice's `min_final_cltv_expiry_delta` time, if present, otherwise - * [`DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA`]. + * The HMAC used to verify the authenticity of these parameters. */ -MUST_USE_RES uint64_t Bolt11Invoice_min_final_cltv_expiry_delta(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +struct LDKStr LSPS2OpeningFeeParams_get_promise(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr); /** - * Returns a list of all fallback addresses as [`Address`]es + * The HMAC used to verify the authenticity of these parameters. */ -MUST_USE_RES struct LDKCVec_StrZ Bolt11Invoice_fallback_addresses(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2OpeningFeeParams_set_promise(struct LDKLSPS2OpeningFeeParams *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Returns a list of all routes included in the invoice + * Constructs a new LSPS2OpeningFeeParams given each field */ -MUST_USE_RES struct LDKCVec_PrivateRouteZ Bolt11Invoice_private_routes(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLSPS2OpeningFeeParams LSPS2OpeningFeeParams_new(uint64_t min_fee_msat_arg, uint32_t proportional_arg, struct LDKLSPSDateTime valid_until_arg, uint32_t min_lifetime_arg, uint32_t max_client_to_self_delay_arg, uint64_t min_payment_size_msat_arg, uint64_t max_payment_size_msat_arg, struct LDKStr promise_arg); /** - * Returns a list of all routes included in the invoice as the underlying hints + * Creates a copy of the LSPS2OpeningFeeParams */ -MUST_USE_RES struct LDKCVec_RouteHintZ Bolt11Invoice_route_hints(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +struct LDKLSPS2OpeningFeeParams LSPS2OpeningFeeParams_clone(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR orig); /** - * Returns the currency for which the invoice was issued + * Checks if two LSPS2OpeningFeeParamss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES enum LDKCurrency Bolt11Invoice_currency(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +bool LSPS2OpeningFeeParams_eq(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR a, const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR b); /** - * Returns the amount if specified in the invoice as millisatoshis. + * Frees any resources used by the LSPS2GetInfoResponse, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCOption_u64Z Bolt11Invoice_amount_milli_satoshis(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +void LSPS2GetInfoResponse_free(struct LDKLSPS2GetInfoResponse this_obj); /** - * Creates a new `Description` if `description` is at most 1023 * 5 bits (i.e., 639 bytes) - * long, and returns [`CreationError::DescriptionTooLong`] otherwise. - * - * Please note that single characters may use more than one byte due to UTF8 encoding. + * A set of opening fee parameters. */ -MUST_USE_RES struct LDKCResult_DescriptionCreationErrorZ Description_new(struct LDKStr description); +struct LDKCVec_LSPS2OpeningFeeParamsZ LSPS2GetInfoResponse_get_opening_fee_params_menu(const struct LDKLSPS2GetInfoResponse *NONNULL_PTR this_ptr); /** - * Creates an empty `Description`. + * A set of opening fee parameters. */ -MUST_USE_RES struct LDKDescription Description_empty(void); +void LSPS2GetInfoResponse_set_opening_fee_params_menu(struct LDKLSPS2GetInfoResponse *NONNULL_PTR this_ptr, struct LDKCVec_LSPS2OpeningFeeParamsZ val); /** - * Returns the underlying description [`UntrustedString`] + * Constructs a new LSPS2GetInfoResponse given each field */ -MUST_USE_RES struct LDKUntrustedString Description_into_inner(struct LDKDescription this_arg); +MUST_USE_RES struct LDKLSPS2GetInfoResponse LSPS2GetInfoResponse_new(struct LDKCVec_LSPS2OpeningFeeParamsZ opening_fee_params_menu_arg); /** - * Get a reference to the underlying description [`UntrustedString`] + * Creates a copy of the LSPS2GetInfoResponse */ -MUST_USE_RES struct LDKUntrustedString Description_as_inner(const struct LDKDescription *NONNULL_PTR this_arg); +struct LDKLSPS2GetInfoResponse LSPS2GetInfoResponse_clone(const struct LDKLSPS2GetInfoResponse *NONNULL_PTR orig); /** - * Get the string representation of a Description object + * Checks if two LSPS2GetInfoResponses contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKStr Description_to_str(const struct LDKDescription *NONNULL_PTR o); +bool LSPS2GetInfoResponse_eq(const struct LDKLSPS2GetInfoResponse *NONNULL_PTR a, const struct LDKLSPS2GetInfoResponse *NONNULL_PTR b); /** - * Construct an `ExpiryTime` from seconds. + * Frees any resources used by the LSPS2BuyRequest, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKExpiryTime ExpiryTime_from_seconds(uint64_t seconds); +void LSPS2BuyRequest_free(struct LDKLSPS2BuyRequest this_obj); /** - * Construct an `ExpiryTime` from a [`Duration`], dropping the sub-second part. + * The fee parameters you would like to use. */ -MUST_USE_RES struct LDKExpiryTime ExpiryTime_from_duration(uint64_t duration); +struct LDKLSPS2OpeningFeeParams LSPS2BuyRequest_get_opening_fee_params(const struct LDKLSPS2BuyRequest *NONNULL_PTR this_ptr); /** - * Returns the expiry time in seconds + * The fee parameters you would like to use. */ -MUST_USE_RES uint64_t ExpiryTime_as_seconds(const struct LDKExpiryTime *NONNULL_PTR this_arg); +void LSPS2BuyRequest_set_opening_fee_params(struct LDKLSPS2BuyRequest *NONNULL_PTR this_ptr, struct LDKLSPS2OpeningFeeParams val); /** - * Returns a reference to the underlying [`Duration`] (=expiry time) + * The size of the initial payment you expect to receive. */ -MUST_USE_RES uint64_t ExpiryTime_as_duration(const struct LDKExpiryTime *NONNULL_PTR this_arg); +struct LDKCOption_u64Z LSPS2BuyRequest_get_payment_size_msat(const struct LDKLSPS2BuyRequest *NONNULL_PTR this_ptr); /** - * Creates a new (partial) route from a list of hops + * The size of the initial payment you expect to receive. */ -MUST_USE_RES struct LDKCResult_PrivateRouteCreationErrorZ PrivateRoute_new(struct LDKRouteHint hops); +void LSPS2BuyRequest_set_payment_size_msat(struct LDKLSPS2BuyRequest *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Returns the underlying list of hops + * Constructs a new LSPS2BuyRequest given each field */ -MUST_USE_RES struct LDKRouteHint PrivateRoute_into_inner(struct LDKPrivateRoute this_arg); +MUST_USE_RES struct LDKLSPS2BuyRequest LSPS2BuyRequest_new(struct LDKLSPS2OpeningFeeParams opening_fee_params_arg, struct LDKCOption_u64Z payment_size_msat_arg); /** - * Creates a copy of the CreationError + * Creates a copy of the LSPS2BuyRequest */ -enum LDKCreationError CreationError_clone(const enum LDKCreationError *NONNULL_PTR orig); +struct LDKLSPS2BuyRequest LSPS2BuyRequest_clone(const struct LDKLSPS2BuyRequest *NONNULL_PTR orig); /** - * Utility method to constructs a new DescriptionTooLong-variant CreationError + * Checks if two LSPS2BuyRequests contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -enum LDKCreationError CreationError_description_too_long(void); +bool LSPS2BuyRequest_eq(const struct LDKLSPS2BuyRequest *NONNULL_PTR a, const struct LDKLSPS2BuyRequest *NONNULL_PTR b); /** - * Utility method to constructs a new RouteTooLong-variant CreationError + * Frees any resources used by the LSPS2InterceptScid, if is_owned is set and inner is non-NULL. */ -enum LDKCreationError CreationError_route_too_long(void); +void LSPS2InterceptScid_free(struct LDKLSPS2InterceptScid this_obj); /** - * Utility method to constructs a new TimestampOutOfBounds-variant CreationError + * Creates a copy of the LSPS2InterceptScid */ -enum LDKCreationError CreationError_timestamp_out_of_bounds(void); +struct LDKLSPS2InterceptScid LSPS2InterceptScid_clone(const struct LDKLSPS2InterceptScid *NONNULL_PTR orig); /** - * Utility method to constructs a new InvalidAmount-variant CreationError + * Checks if two LSPS2InterceptScids contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -enum LDKCreationError CreationError_invalid_amount(void); +bool LSPS2InterceptScid_eq(const struct LDKLSPS2InterceptScid *NONNULL_PTR a, const struct LDKLSPS2InterceptScid *NONNULL_PTR b); /** - * Utility method to constructs a new MissingRouteHints-variant CreationError + * Try to convert a [`LSPS2InterceptScid`] into a u64 used by LDK. */ -enum LDKCreationError CreationError_missing_route_hints(void); +MUST_USE_RES struct LDKCResult_u64NoneZ LSPS2InterceptScid_to_scid(const struct LDKLSPS2InterceptScid *NONNULL_PTR this_arg); /** - * Utility method to constructs a new MinFinalCltvExpiryDeltaTooShort-variant CreationError + * Frees any resources used by the LSPS2BuyResponse, if is_owned is set and inner is non-NULL. */ -enum LDKCreationError CreationError_min_final_cltv_expiry_delta_too_short(void); +void LSPS2BuyResponse_free(struct LDKLSPS2BuyResponse this_obj); /** - * Checks if two CreationErrors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * The intercept short channel id used by LSP to identify need to open channel. */ -bool CreationError_eq(const enum LDKCreationError *NONNULL_PTR a, const enum LDKCreationError *NONNULL_PTR b); +struct LDKLSPS2InterceptScid LSPS2BuyResponse_get_jit_channel_scid(const struct LDKLSPS2BuyResponse *NONNULL_PTR this_ptr); /** - * Get the string representation of a CreationError object + * The intercept short channel id used by LSP to identify need to open channel. */ -struct LDKStr CreationError_to_str(const enum LDKCreationError *NONNULL_PTR o); +void LSPS2BuyResponse_set_jit_channel_scid(struct LDKLSPS2BuyResponse *NONNULL_PTR this_ptr, struct LDKLSPS2InterceptScid val); /** - * Creates a copy of the Bolt11SemanticError + * The locktime expiry delta the lsp requires. */ -enum LDKBolt11SemanticError Bolt11SemanticError_clone(const enum LDKBolt11SemanticError *NONNULL_PTR orig); +uint32_t LSPS2BuyResponse_get_lsp_cltv_expiry_delta(const struct LDKLSPS2BuyResponse *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new NoPaymentHash-variant Bolt11SemanticError + * The locktime expiry delta the lsp requires. */ -enum LDKBolt11SemanticError Bolt11SemanticError_no_payment_hash(void); +void LSPS2BuyResponse_set_lsp_cltv_expiry_delta(struct LDKLSPS2BuyResponse *NONNULL_PTR this_ptr, uint32_t val); /** - * Utility method to constructs a new MultiplePaymentHashes-variant Bolt11SemanticError + * A flag that indicates who is trusting who. */ -enum LDKBolt11SemanticError Bolt11SemanticError_multiple_payment_hashes(void); +bool LSPS2BuyResponse_get_client_trusts_lsp(const struct LDKLSPS2BuyResponse *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new NoDescription-variant Bolt11SemanticError + * A flag that indicates who is trusting who. */ -enum LDKBolt11SemanticError Bolt11SemanticError_no_description(void); +void LSPS2BuyResponse_set_client_trusts_lsp(struct LDKLSPS2BuyResponse *NONNULL_PTR this_ptr, bool val); /** - * Utility method to constructs a new MultipleDescriptions-variant Bolt11SemanticError + * Constructs a new LSPS2BuyResponse given each field */ -enum LDKBolt11SemanticError Bolt11SemanticError_multiple_descriptions(void); +MUST_USE_RES struct LDKLSPS2BuyResponse LSPS2BuyResponse_new(struct LDKLSPS2InterceptScid jit_channel_scid_arg, uint32_t lsp_cltv_expiry_delta_arg, bool client_trusts_lsp_arg); /** - * Utility method to constructs a new NoPaymentSecret-variant Bolt11SemanticError + * Creates a copy of the LSPS2BuyResponse */ -enum LDKBolt11SemanticError Bolt11SemanticError_no_payment_secret(void); +struct LDKLSPS2BuyResponse LSPS2BuyResponse_clone(const struct LDKLSPS2BuyResponse *NONNULL_PTR orig); /** - * Utility method to constructs a new MultiplePaymentSecrets-variant Bolt11SemanticError + * Checks if two LSPS2BuyResponses contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -enum LDKBolt11SemanticError Bolt11SemanticError_multiple_payment_secrets(void); +bool LSPS2BuyResponse_eq(const struct LDKLSPS2BuyResponse *NONNULL_PTR a, const struct LDKLSPS2BuyResponse *NONNULL_PTR b); /** - * Utility method to constructs a new InvalidFeatures-variant Bolt11SemanticError + * Frees any resources used by the LSPS2Request */ -enum LDKBolt11SemanticError Bolt11SemanticError_invalid_features(void); +void LSPS2Request_free(struct LDKLSPS2Request this_ptr); /** - * Utility method to constructs a new InvalidRecoveryId-variant Bolt11SemanticError + * Creates a copy of the LSPS2Request */ -enum LDKBolt11SemanticError Bolt11SemanticError_invalid_recovery_id(void); +struct LDKLSPS2Request LSPS2Request_clone(const struct LDKLSPS2Request *NONNULL_PTR orig); /** - * Utility method to constructs a new InvalidSignature-variant Bolt11SemanticError + * Utility method to constructs a new GetInfo-variant LSPS2Request */ -enum LDKBolt11SemanticError Bolt11SemanticError_invalid_signature(void); +struct LDKLSPS2Request LSPS2Request_get_info(struct LDKLSPS2GetInfoRequest a); /** - * Utility method to constructs a new ImpreciseAmount-variant Bolt11SemanticError + * Utility method to constructs a new Buy-variant LSPS2Request */ -enum LDKBolt11SemanticError Bolt11SemanticError_imprecise_amount(void); +struct LDKLSPS2Request LSPS2Request_buy(struct LDKLSPS2BuyRequest a); /** - * Checks if two Bolt11SemanticErrors contain equal inner contents. + * Checks if two LSPS2Requests contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. */ -bool Bolt11SemanticError_eq(const enum LDKBolt11SemanticError *NONNULL_PTR a, const enum LDKBolt11SemanticError *NONNULL_PTR b); +bool LSPS2Request_eq(const struct LDKLSPS2Request *NONNULL_PTR a, const struct LDKLSPS2Request *NONNULL_PTR b); /** - * Get the string representation of a Bolt11SemanticError object + * Frees any resources used by the LSPS2Response */ -struct LDKStr Bolt11SemanticError_to_str(const enum LDKBolt11SemanticError *NONNULL_PTR o); +void LSPS2Response_free(struct LDKLSPS2Response this_ptr); /** - * Frees any resources used by the SignOrCreationError + * Creates a copy of the LSPS2Response */ -void SignOrCreationError_free(struct LDKSignOrCreationError this_ptr); +struct LDKLSPS2Response LSPS2Response_clone(const struct LDKLSPS2Response *NONNULL_PTR orig); /** - * Creates a copy of the SignOrCreationError + * Utility method to constructs a new GetInfo-variant LSPS2Response */ -struct LDKSignOrCreationError SignOrCreationError_clone(const struct LDKSignOrCreationError *NONNULL_PTR orig); +struct LDKLSPS2Response LSPS2Response_get_info(struct LDKLSPS2GetInfoResponse a); /** - * Utility method to constructs a new SignError-variant SignOrCreationError + * Utility method to constructs a new GetInfoError-variant LSPS2Response */ -struct LDKSignOrCreationError SignOrCreationError_sign_error(void); +struct LDKLSPS2Response LSPS2Response_get_info_error(struct LDKLSPSResponseError a); /** - * Utility method to constructs a new CreationError-variant SignOrCreationError + * Utility method to constructs a new Buy-variant LSPS2Response */ -struct LDKSignOrCreationError SignOrCreationError_creation_error(enum LDKCreationError a); +struct LDKLSPS2Response LSPS2Response_buy(struct LDKLSPS2BuyResponse a); /** - * Checks if two SignOrCreationErrors contain equal inner contents. + * Utility method to constructs a new BuyError-variant LSPS2Response + */ +struct LDKLSPS2Response LSPS2Response_buy_error(struct LDKLSPSResponseError a); + +/** + * Checks if two LSPS2Responses contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. */ -bool SignOrCreationError_eq(const struct LDKSignOrCreationError *NONNULL_PTR a, const struct LDKSignOrCreationError *NONNULL_PTR b); +bool LSPS2Response_eq(const struct LDKLSPS2Response *NONNULL_PTR a, const struct LDKLSPS2Response *NONNULL_PTR b); /** - * Get the string representation of a SignOrCreationError object + * Frees any resources used by the LSPS2Message */ -struct LDKStr SignOrCreationError_to_str(const struct LDKSignOrCreationError *NONNULL_PTR o); +void LSPS2Message_free(struct LDKLSPS2Message this_ptr); /** - * Read a SiPrefix object from a string + * Creates a copy of the LSPS2Message */ -struct LDKCResult_SiPrefixBolt11ParseErrorZ SiPrefix_from_str(struct LDKStr s); +struct LDKLSPS2Message LSPS2Message_clone(const struct LDKLSPS2Message *NONNULL_PTR orig); /** - * Read a Bolt11Invoice object from a string + * Utility method to constructs a new Request-variant LSPS2Message */ -struct LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ Bolt11Invoice_from_str(struct LDKStr s); +struct LDKLSPS2Message LSPS2Message_request(struct LDKLSPSRequestId a, struct LDKLSPS2Request b); /** - * Read a SignedRawBolt11Invoice object from a string + * Utility method to constructs a new Response-variant LSPS2Message */ -struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ SignedRawBolt11Invoice_from_str(struct LDKStr s); +struct LDKLSPS2Message LSPS2Message_response(struct LDKLSPSRequestId a, struct LDKLSPS2Response b); /** - * Get the string representation of a Bolt11ParseError object + * Checks if two LSPS2Messages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKStr Bolt11ParseError_to_str(const struct LDKBolt11ParseError *NONNULL_PTR o); +bool LSPS2Message_eq(const struct LDKLSPS2Message *NONNULL_PTR a, const struct LDKLSPS2Message *NONNULL_PTR b); /** - * Get the string representation of a ParseOrSemanticError object + * Frees any resources used by the LSPS2ServiceConfig, if is_owned is set and inner is non-NULL. */ -struct LDKStr ParseOrSemanticError_to_str(const struct LDKParseOrSemanticError *NONNULL_PTR o); +void LSPS2ServiceConfig_free(struct LDKLSPS2ServiceConfig this_obj); /** - * Get the string representation of a Bolt11Invoice object + * Used to calculate the promise for channel parameters supplied to clients. + * + * Note: If this changes then old promises given out will be considered invalid. */ -struct LDKStr Bolt11Invoice_to_str(const struct LDKBolt11Invoice *NONNULL_PTR o); +const uint8_t (*LSPS2ServiceConfig_get_promise_secret(const struct LDKLSPS2ServiceConfig *NONNULL_PTR this_ptr))[32]; /** - * Get the string representation of a SignedRawBolt11Invoice object + * Used to calculate the promise for channel parameters supplied to clients. + * + * Note: If this changes then old promises given out will be considered invalid. */ -struct LDKStr SignedRawBolt11Invoice_to_str(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR o); +void LSPS2ServiceConfig_set_promise_secret(struct LDKLSPS2ServiceConfig *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Get the string representation of a Currency object + * Constructs a new LSPS2ServiceConfig given each field */ -struct LDKStr Currency_to_str(const enum LDKCurrency *NONNULL_PTR o); +MUST_USE_RES struct LDKLSPS2ServiceConfig LSPS2ServiceConfig_new(struct LDKThirtyTwoBytes promise_secret_arg); /** - * Get the string representation of a SiPrefix object + * Creates a copy of the LSPS2ServiceConfig */ -struct LDKStr SiPrefix_to_str(const enum LDKSiPrefix *NONNULL_PTR o); +struct LDKLSPS2ServiceConfig LSPS2ServiceConfig_clone(const struct LDKLSPS2ServiceConfig *NONNULL_PTR orig); /** - * Frees any resources used by the GraphSyncError + * Frees any resources used by the LSPS2ServiceHandler, if is_owned is set and inner is non-NULL. */ -void GraphSyncError_free(struct LDKGraphSyncError this_ptr); +void LSPS2ServiceHandler_free(struct LDKLSPS2ServiceHandler this_obj); /** - * Creates a copy of the GraphSyncError + * Used by LSP to inform a client requesting a JIT Channel the token they used is invalid. + * + * Should be called in response to receiving a [`LSPS2ServiceEvent::GetInfo`] event. + * + * [`LSPS2ServiceEvent::GetInfo`]: crate::lsps2::event::LSPS2ServiceEvent::GetInfo */ -struct LDKGraphSyncError GraphSyncError_clone(const struct LDKGraphSyncError *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ LSPS2ServiceHandler_invalid_token_provided(const struct LDKLSPS2ServiceHandler *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKLSPSRequestId request_id); /** - * Utility method to constructs a new DecodeError-variant GraphSyncError + * Used by LSP to provide fee parameters to a client requesting a JIT Channel. + * + * Should be called in response to receiving a [`LSPS2ServiceEvent::GetInfo`] event. + * + * [`LSPS2ServiceEvent::GetInfo`]: crate::lsps2::event::LSPS2ServiceEvent::GetInfo */ -struct LDKGraphSyncError GraphSyncError_decode_error(struct LDKDecodeError a); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ LSPS2ServiceHandler_opening_fee_params_generated(const struct LDKLSPS2ServiceHandler *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKLSPSRequestId request_id, struct LDKCVec_LSPS2RawOpeningFeeParamsZ opening_fee_params_menu); /** - * Utility method to constructs a new LightningError-variant GraphSyncError + * Used by LSP to provide client with the intercept scid and cltv_expiry_delta to use in their invoice. + * + * Should be called in response to receiving a [`LSPS2ServiceEvent::BuyRequest`] event. + * + * [`LSPS2ServiceEvent::BuyRequest`]: crate::lsps2::event::LSPS2ServiceEvent::BuyRequest */ -struct LDKGraphSyncError GraphSyncError_lightning_error(struct LDKLightningError a); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ LSPS2ServiceHandler_invoice_parameters_generated(const struct LDKLSPS2ServiceHandler *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKLSPSRequestId request_id, uint64_t intercept_scid, uint32_t cltv_expiry_delta, bool client_trusts_lsp, struct LDKU128 user_channel_id); /** - * Frees any resources used by the RapidGossipSync, if is_owned is set and inner is non-NULL. + * Forward [`Event::HTLCIntercepted`] event parameters into this function. + * + * Will fail the intercepted HTLC if the intercept scid matches a payment we are expecting + * but the payment amount is incorrect or the expiry has passed. + * + * Will generate a [`LSPS2ServiceEvent::OpenChannel`] event if the intercept scid matches a payment we are expected + * and the payment amount is correct and the offer has not expired. + * + * Will do nothing if the intercept scid does not match any of the ones we gave out. + * + * [`Event::HTLCIntercepted`]: lightning::events::Event::HTLCIntercepted + * [`LSPS2ServiceEvent::OpenChannel`]: crate::lsps2::event::LSPS2ServiceEvent::OpenChannel */ -void RapidGossipSync_free(struct LDKRapidGossipSync this_obj); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ LSPS2ServiceHandler_htlc_intercepted(const struct LDKLSPS2ServiceHandler *NONNULL_PTR this_arg, uint64_t intercept_scid, struct LDKThirtyTwoBytes intercept_id, uint64_t expected_outbound_amount_msat, struct LDKThirtyTwoBytes payment_hash); /** - * Instantiate a new [`RapidGossipSync`] instance. + * Forward [`Event::HTLCHandlingFailed`] event parameter into this function. + * + * Will attempt to forward the next payment in the queue if one is present. + * Will do nothing if the intercept scid does not match any of the ones we gave out + * or if the payment queue is empty + * + * [`Event::HTLCHandlingFailed`]: lightning::events::Event::HTLCHandlingFailed */ -MUST_USE_RES struct LDKRapidGossipSync RapidGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ LSPS2ServiceHandler_htlc_handling_failed(const struct LDKLSPS2ServiceHandler *NONNULL_PTR this_arg, struct LDKHTLCDestination failed_next_destination); /** - * Sync gossip data from a file. - * Returns the last sync timestamp to be used the next time rapid sync data is queried. + * Forward [`Event::PaymentForwarded`] event parameter into this function. * - * `network_graph`: The network graph to apply the updates to + * Will register the forwarded payment as having paid the JIT channel fee, and forward any held + * and future HTLCs for the SCID of the initial invoice. In the future, this will verify the + * `skimmed_fee_msat` in [`Event::PaymentForwarded`]. * - * `sync_path`: Path to the file where the gossip update data is located + * Note that `next_channel_id` is required to be provided. Therefore, the corresponding + * [`Event::PaymentForwarded`] events need to be generated and serialized by LDK versions + * greater or equal to 0.0.107. * + * [`Event::PaymentForwarded`]: lightning::events::Event::PaymentForwarded */ -MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_sync_network_graph_with_file_path(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKStr sync_path); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ LSPS2ServiceHandler_payment_forwarded(const struct LDKLSPS2ServiceHandler *NONNULL_PTR this_arg, struct LDKChannelId next_channel_id); /** - * Update network graph from binary data. - * Returns the last sync timestamp to be used the next time rapid sync data is queried. + * Forward [`Event::ChannelReady`] event parameters into this function. * - * `update_data`: `&[u8]` binary stream that comprises the update data + * Will forward the intercepted HTLC if it matches a channel + * we need to forward a payment over otherwise it will be ignored. + * + * [`Event::ChannelReady`]: lightning::events::Event::ChannelReady */ -MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ LSPS2ServiceHandler_channel_ready(const struct LDKLSPS2ServiceHandler *NONNULL_PTR this_arg, struct LDKU128 user_channel_id, const struct LDKChannelId *NONNULL_PTR channel_id, struct LDKPublicKey counterparty_node_id); /** - * Update network graph from binary data. - * Returns the last sync timestamp to be used the next time rapid sync data is queried. + * Determines if the given parameters are valid given the secret used to generate the promise. + */ +bool is_valid_opening_fee_params(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR fee_params, const uint8_t (*promise_secret)[32]); + +/** + * Determines if the given parameters are expired, or still valid. + */ +bool is_expired_opening_fee_params(const struct LDKLSPS2OpeningFeeParams *NONNULL_PTR fee_params); + +/** + * Computes the opening fee given a payment size and the fee parameters. * - * `update_data`: `&[u8]` binary stream that comprises the update data - * `current_time_unix`: `Option` optional current timestamp to verify data age + * Returns [`Option::None`] when the computation overflows. + * + * See the [`specification`](https://github.com/lightning/blips/blob/master/blip-0052.md#computing-the-opening_fee) for more details. */ -MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph_no_std(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data, struct LDKCOption_u64Z current_time_unix); +struct LDKCOption_u64Z compute_opening_fee(uint64_t payment_size_msat, uint64_t opening_fee_min_fee_msat, uint64_t opening_fee_proportional); /** - * Returns whether a rapid gossip sync has completed at least once. + * Frees any resources used by the MessageQueue, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool RapidGossipSync_is_initial_sync_complete(const struct LDKRapidGossipSync *NONNULL_PTR this_arg); +void MessageQueue_free(struct LDKMessageQueue this_obj); + +/** + * Calls the free function if one is set + */ +void ProcessMessagesCallback_free(struct LDKProcessMessagesCallback this_ptr); #endif /* LDK_C_BINDINGS_H */ diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index 6d6be13f..270b007a 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -15,6 +15,7 @@ class DNSSECQuery; class DNSSECProof; class HumanReadableName; class OMNameResolver; +class LSPS0ClientHandler; class InvoiceWithExplicitSigningPubkeyBuilder; class InvoiceWithDerivedSigningPubkeyBuilder; class UnsignedBolt12Invoice; @@ -55,6 +56,11 @@ class PrivateHopCandidate; class BlindedPathCandidate; class OneHopBlindedPathCandidate; class CandidateRouteHop; +class LSPS0ListProtocolsRequest; +class LSPS0ListProtocolsResponse; +class LSPS0Request; +class LSPS0Response; +class LSPS0Message; class UntrustedString; class PrintableString; class ScoreLookUp; @@ -77,6 +83,12 @@ class ChannelMonitorUpdateStatus; class Watch; class Filter; class WatchedOutput; +class LSPS1ClientConfig; +class LSPS1ClientHandler; +class LSPS2ClientConfig; +class LSPS2ClientHandler; +class LSPS2ClientEvent; +class LSPS2ServiceEvent; class OfferId; class OfferWithExplicitMetadataBuilder; class OfferWithDerivedMetadataBuilder; @@ -129,6 +141,8 @@ class APIError; class TaggedHash; class SignError; class EcdsaChannelSigner; +class LSPS2ServiceConfig; +class LSPS2ServiceHandler; class ChannelMonitorUpdate; class MonitorEvent; class HTLCUpdate; @@ -146,6 +160,7 @@ class PeerHandleError; class PeerManager; class GraphSyncError; class RapidGossipSync; +class LSPS1ClientEvent; class KVStore; class MigratableKVStore; class Persister; @@ -224,6 +239,24 @@ class OnionMessageHandler; class FinalOnionHopData; class OnionPacket; class TrampolineOnionPacket; +class LSPS1OrderId; +class LSPS1GetInfoRequest; +class LSPS1Options; +class LSPS1GetInfoResponse; +class LSPS1CreateOrderRequest; +class LSPS1OrderParams; +class LSPS1CreateOrderResponse; +class LSPS1OrderState; +class LSPS1PaymentInfo; +class LSPS1Bolt11PaymentInfo; +class LSPS1OnchainPaymentInfo; +class LSPS1PaymentState; +class LSPS1OnchainPayment; +class LSPS1ChannelInfo; +class LSPS1GetOrderRequest; +class LSPS1Request; +class LSPS1Response; +class LSPS1Message; class Level; class Record; class Logger; @@ -238,6 +271,11 @@ class ChannelShutdownState; class FutureCallback; class Future; class Sleeper; +class RawLSPSMessage; +class LSPSRequestId; +class LSPSDateTime; +class LSPSResponseError; +class LSPSMessage; class AsyncPaymentsMessageHandler; class AsyncPaymentsMessage; class HeldHtlcAvailable; @@ -265,6 +303,16 @@ class Bolt12SemanticError; class BroadcasterInterface; class ConfirmationTarget; class FeeEstimator; +class LSPS2GetInfoRequest; +class LSPS2RawOpeningFeeParams; +class LSPS2OpeningFeeParams; +class LSPS2GetInfoResponse; +class LSPS2BuyRequest; +class LSPS2InterceptScid; +class LSPS2BuyResponse; +class LSPS2Request; +class LSPS2Response; +class LSPS2Message; class Packet; class ParsedOnionMessageContents; class OnionMessageContents; @@ -325,6 +373,7 @@ class PaymentConstraints; class PaymentContext; class Bolt12OfferContext; class Bolt12RefundContext; +class LSPS0ClientEvent; class UtxoLookupError; class UtxoResult; class UtxoLookup; @@ -356,6 +405,9 @@ class Direction; class NodeIdLookUp; class EmptyNodeIdLookUp; class BlindedHop; +class LiquidityEvent; +class MessageQueue; +class ProcessMessagesCallback; class InvoiceError; class ErroneousField; class TrackedSpendableOutput; @@ -371,6 +423,7 @@ class RevocationKey; class Persist; class LockedChannelMonitor; class ChainMonitor; +class LSPS0ServiceHandler; class BlindedMessagePath; class NextMessageHop; class MessageForwardNode; @@ -491,6 +544,7 @@ class CVec_C2Tuple_ChannelIdPublicKeyZZ; class C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ; class CResult_ChannelTransactionParametersDecodeErrorZ; class CResult_DelayedPaymentOutputDescriptorDecodeErrorZ; +class CResult_LSPSRequestIdAPIErrorZ; class CResult_InFlightHtlcsDecodeErrorZ; class CResult_CommitmentSignedBatchDecodeErrorZ; class CResult_COption_HTLCDestinationZDecodeErrorZ; @@ -504,11 +558,12 @@ class CResult_BlindedHopDecodeErrorZ; class CResult_NoneLightningErrorZ; class CResult_FixedPenaltyScorerDecodeErrorZ; class CResult_NonePeerHandleErrorZ; -class CResult_TrustedCommitmentTransactionNoneZ; +class CResult_RawLSPSMessageDecodeErrorZ; class CResult_FinalOnionHopDataDecodeErrorZ; -class CResult_COption_EventZDecodeErrorZ; +class CResult_TrustedCommitmentTransactionNoneZ; class CResult_DNSResolverMessageDecodeErrorZ; class C2Tuple_PublicKeyChannelIdZ; +class CResult_COption_EventZDecodeErrorZ; class COption_SocketAddressZ; class CResult_COption_MonitorEventZDecodeErrorZ; class COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ; @@ -555,11 +610,12 @@ class CResult_COption_ClosureReasonZDecodeErrorZ; class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; class CResult_NonceDecodeErrorZ; class CResult_RouteParametersDecodeErrorZ; +class CResult_LSPSDateTimeNoneZ; +class CResult_u64NoneZ; +class CResult_NodeAliasDecodeErrorZ; class CResult_PrivateRouteCreationErrorZ; class CResult_InvoiceErrorDecodeErrorZ; -class CResult_NodeAliasDecodeErrorZ; class C2Tuple_BestBlockOutputSweeperZ; -class C2Tuple_OutPointCVec_u64ZZ; class CVec_UpdateFulfillHTLCZ; class CVec_C2Tuple_u32CVec_u8ZZZ; class C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ; @@ -586,6 +642,7 @@ class C2Tuple_boolboolZ; class CVec_PaymentForwardNodeZ; class CResult_TrackedSpendableOutputDecodeErrorZ; class CVec_SpendableOutputDescriptorZ; +class C2Tuple_OutPointCVec_u64ZZ; class CResult_ResponderDecodeErrorZ; class C2Tuple_OutPointCVec_u8ZZ; class CResult_WitnessNoneZ; @@ -598,6 +655,7 @@ class CResult_TxInitRbfDecodeErrorZ; class COption_WriteableScoreZ; class CVec_StrZ; class CResult_AsyncPaymentsMessageDecodeErrorZ; +class CVec_LSPS2OpeningFeeParamsZ; class CResult_SpliceAckDecodeErrorZ; class CResult_PositiveTimestampCreationErrorZ; class CResult_PeeledOnionNoneZ; @@ -650,13 +708,14 @@ class CResult_FundingSignedDecodeErrorZ; class CResult_RecoverableSignatureNoneZ; class CResult_SocketAddressDecodeErrorZ; class C2Tuple_Z; -class CResult_TxCreationKeysDecodeErrorZ; +class COption_AddressZ; class CResult_InboundHTLCDetailsDecodeErrorZ; -class CResult_ShutdownScriptDecodeErrorZ; +class CResult_TxCreationKeysDecodeErrorZ; class C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ; -class CResult_SiPrefixBolt11ParseErrorZ; +class CResult_ShutdownScriptDecodeErrorZ; class CVec_PathZ; class CResult_NetworkGraphDecodeErrorZ; +class CResult_SiPrefixBolt11ParseErrorZ; class CResult_NodeInfoDecodeErrorZ; class CVec_NodeIdZ; class CVec_u8Z; @@ -677,14 +736,15 @@ class CResult_AsyncPaymentsContextDecodeErrorZ; class C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ; class CResult_OfferBolt12SemanticErrorZ; class CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ; +class CVec_LSPS2RawOpeningFeeParamsZ; class CResult_InitDecodeErrorZ; class CResult_PaymentPurposeDecodeErrorZ; class CResult_ClaimedHTLCDecodeErrorZ; -class CResult_OutPointDecodeErrorZ; class CVec_ChannelDetailsZ; -class CResult_DNSResolverContextDecodeErrorZ; +class CResult_OutPointDecodeErrorZ; class CVec_MessageSendEventZ; class CResult_Bolt11InvoiceFeaturesDecodeErrorZ; +class CResult_DNSResolverContextDecodeErrorZ; class CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ; class CResult_RouteHintHopDecodeErrorZ; class CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ; @@ -727,13 +787,13 @@ class CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ; class CResult_PaymentConstraintsDecodeErrorZ; class C2Tuple_u32CVec_u8ZZ; class CVec_C2Tuple_PublicKeyTypeZZ; +class CVec_u16Z; class CResult_OutboundHTLCDetailsDecodeErrorZ; -class CResult_OnionMessagePathNoneZ; class CResult_RefundBolt12ParseErrorZ; class CResult_u32GraphSyncErrorZ; class CVec_C2Tuple_u64CVec_u8ZZZ; class CResult_OffersMessageDecodeErrorZ; -class CVec_PhantomRouteHintsZ; +class CResult_OnionMessagePathNoneZ; class CResult_NoneAPIErrorZ; class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ; class COption_f64Z; @@ -758,6 +818,7 @@ class CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZProbeSendFailureZ; class CResult_ChannelConfigDecodeErrorZ; class COption_i64Z; class CVec_PrivateRouteZ; +class CVec_PhantomRouteHintsZ; class CVec_C2Tuple_OutPointCVec_u64ZZZ; class C2Tuple_ThirtyTwoBytesChannelManagerZ; class CResult_COption_OnionMessageContentsZDecodeErrorZ; @@ -772,14 +833,15 @@ class CResult_TxOutUtxoLookupErrorZ; class COption_usizeZ; class CVec_BlindedMessagePathZ; class CResult_OffersContextDecodeErrorZ; +class CVec_AddressZ; class CResult_NoneNoneZ; class CResult_boolPeerHandleErrorZ; -class CResult_ChannelUpdateDecodeErrorZ; class COption_TxOutZ; +class CResult_ChannelUpdateDecodeErrorZ; class COption_ClosureReasonZ; -class CResult_TransactionU16LenLimitedDecodeErrorZ; class CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ; class CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ; +class CResult_TransactionU16LenLimitedDecodeErrorZ; class CResult_FundingInfoDecodeErrorZ; class COption_AmountZ; class C2Tuple_DNSSECQueryDNSResolverContextZ; @@ -1037,6 +1099,21 @@ class OMNameResolver { const LDKOMNameResolver* operator &() const { return &self; } const LDKOMNameResolver* operator ->() const { return &self; } }; +class LSPS0ClientHandler { +private: + LDKLSPS0ClientHandler self; +public: + LSPS0ClientHandler(const LSPS0ClientHandler&) = delete; + LSPS0ClientHandler(LSPS0ClientHandler&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS0ClientHandler)); } + LSPS0ClientHandler(LDKLSPS0ClientHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS0ClientHandler)); } + operator LDKLSPS0ClientHandler() && { LDKLSPS0ClientHandler res = self; memset(&self, 0, sizeof(LDKLSPS0ClientHandler)); return res; } + ~LSPS0ClientHandler() { LSPS0ClientHandler_free(self); } + LSPS0ClientHandler& operator=(LSPS0ClientHandler&& o) { LSPS0ClientHandler_free(self); self = o.self; memset(&o, 0, sizeof(LSPS0ClientHandler)); return *this; } + LDKLSPS0ClientHandler* operator &() { return &self; } + LDKLSPS0ClientHandler* operator ->() { return &self; } + const LDKLSPS0ClientHandler* operator &() const { return &self; } + const LDKLSPS0ClientHandler* operator ->() const { return &self; } +}; class InvoiceWithExplicitSigningPubkeyBuilder { private: LDKInvoiceWithExplicitSigningPubkeyBuilder self; @@ -1894,6 +1971,81 @@ class CandidateRouteHop { const LDKCandidateRouteHop* operator &() const { return &self; } const LDKCandidateRouteHop* operator ->() const { return &self; } }; +class LSPS0ListProtocolsRequest { +private: + LDKLSPS0ListProtocolsRequest self; +public: + LSPS0ListProtocolsRequest(const LSPS0ListProtocolsRequest&) = delete; + LSPS0ListProtocolsRequest(LSPS0ListProtocolsRequest&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS0ListProtocolsRequest)); } + LSPS0ListProtocolsRequest(LDKLSPS0ListProtocolsRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS0ListProtocolsRequest)); } + operator LDKLSPS0ListProtocolsRequest() && { LDKLSPS0ListProtocolsRequest res = self; memset(&self, 0, sizeof(LDKLSPS0ListProtocolsRequest)); return res; } + ~LSPS0ListProtocolsRequest() { LSPS0ListProtocolsRequest_free(self); } + LSPS0ListProtocolsRequest& operator=(LSPS0ListProtocolsRequest&& o) { LSPS0ListProtocolsRequest_free(self); self = o.self; memset(&o, 0, sizeof(LSPS0ListProtocolsRequest)); return *this; } + LDKLSPS0ListProtocolsRequest* operator &() { return &self; } + LDKLSPS0ListProtocolsRequest* operator ->() { return &self; } + const LDKLSPS0ListProtocolsRequest* operator &() const { return &self; } + const LDKLSPS0ListProtocolsRequest* operator ->() const { return &self; } +}; +class LSPS0ListProtocolsResponse { +private: + LDKLSPS0ListProtocolsResponse self; +public: + LSPS0ListProtocolsResponse(const LSPS0ListProtocolsResponse&) = delete; + LSPS0ListProtocolsResponse(LSPS0ListProtocolsResponse&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS0ListProtocolsResponse)); } + LSPS0ListProtocolsResponse(LDKLSPS0ListProtocolsResponse&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS0ListProtocolsResponse)); } + operator LDKLSPS0ListProtocolsResponse() && { LDKLSPS0ListProtocolsResponse res = self; memset(&self, 0, sizeof(LDKLSPS0ListProtocolsResponse)); return res; } + ~LSPS0ListProtocolsResponse() { LSPS0ListProtocolsResponse_free(self); } + LSPS0ListProtocolsResponse& operator=(LSPS0ListProtocolsResponse&& o) { LSPS0ListProtocolsResponse_free(self); self = o.self; memset(&o, 0, sizeof(LSPS0ListProtocolsResponse)); return *this; } + LDKLSPS0ListProtocolsResponse* operator &() { return &self; } + LDKLSPS0ListProtocolsResponse* operator ->() { return &self; } + const LDKLSPS0ListProtocolsResponse* operator &() const { return &self; } + const LDKLSPS0ListProtocolsResponse* operator ->() const { return &self; } +}; +class LSPS0Request { +private: + LDKLSPS0Request self; +public: + LSPS0Request(const LSPS0Request&) = delete; + LSPS0Request(LSPS0Request&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS0Request)); } + LSPS0Request(LDKLSPS0Request&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS0Request)); } + operator LDKLSPS0Request() && { LDKLSPS0Request res = self; memset(&self, 0, sizeof(LDKLSPS0Request)); return res; } + ~LSPS0Request() { LSPS0Request_free(self); } + LSPS0Request& operator=(LSPS0Request&& o) { LSPS0Request_free(self); self = o.self; memset(&o, 0, sizeof(LSPS0Request)); return *this; } + LDKLSPS0Request* operator &() { return &self; } + LDKLSPS0Request* operator ->() { return &self; } + const LDKLSPS0Request* operator &() const { return &self; } + const LDKLSPS0Request* operator ->() const { return &self; } +}; +class LSPS0Response { +private: + LDKLSPS0Response self; +public: + LSPS0Response(const LSPS0Response&) = delete; + LSPS0Response(LSPS0Response&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS0Response)); } + LSPS0Response(LDKLSPS0Response&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS0Response)); } + operator LDKLSPS0Response() && { LDKLSPS0Response res = self; memset(&self, 0, sizeof(LDKLSPS0Response)); return res; } + ~LSPS0Response() { LSPS0Response_free(self); } + LSPS0Response& operator=(LSPS0Response&& o) { LSPS0Response_free(self); self = o.self; memset(&o, 0, sizeof(LSPS0Response)); return *this; } + LDKLSPS0Response* operator &() { return &self; } + LDKLSPS0Response* operator ->() { return &self; } + const LDKLSPS0Response* operator &() const { return &self; } + const LDKLSPS0Response* operator ->() const { return &self; } +}; +class LSPS0Message { +private: + LDKLSPS0Message self; +public: + LSPS0Message(const LSPS0Message&) = delete; + LSPS0Message(LSPS0Message&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS0Message)); } + LSPS0Message(LDKLSPS0Message&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS0Message)); } + operator LDKLSPS0Message() && { LDKLSPS0Message res = self; memset(&self, 0, sizeof(LDKLSPS0Message)); return res; } + ~LSPS0Message() { LSPS0Message_free(self); } + LSPS0Message& operator=(LSPS0Message&& o) { LSPS0Message_free(self); self = o.self; memset(&o, 0, sizeof(LSPS0Message)); return *this; } + LDKLSPS0Message* operator &() { return &self; } + LDKLSPS0Message* operator ->() { return &self; } + const LDKLSPS0Message* operator &() const { return &self; } + const LDKLSPS0Message* operator ->() const { return &self; } +}; class UntrustedString { private: LDKUntrustedString self; @@ -2407,6 +2559,96 @@ class WatchedOutput { const LDKWatchedOutput* operator &() const { return &self; } const LDKWatchedOutput* operator ->() const { return &self; } }; +class LSPS1ClientConfig { +private: + LDKLSPS1ClientConfig self; +public: + LSPS1ClientConfig(const LSPS1ClientConfig&) = delete; + LSPS1ClientConfig(LSPS1ClientConfig&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1ClientConfig)); } + LSPS1ClientConfig(LDKLSPS1ClientConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1ClientConfig)); } + operator LDKLSPS1ClientConfig() && { LDKLSPS1ClientConfig res = self; memset(&self, 0, sizeof(LDKLSPS1ClientConfig)); return res; } + ~LSPS1ClientConfig() { LSPS1ClientConfig_free(self); } + LSPS1ClientConfig& operator=(LSPS1ClientConfig&& o) { LSPS1ClientConfig_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1ClientConfig)); return *this; } + LDKLSPS1ClientConfig* operator &() { return &self; } + LDKLSPS1ClientConfig* operator ->() { return &self; } + const LDKLSPS1ClientConfig* operator &() const { return &self; } + const LDKLSPS1ClientConfig* operator ->() const { return &self; } +}; +class LSPS1ClientHandler { +private: + LDKLSPS1ClientHandler self; +public: + LSPS1ClientHandler(const LSPS1ClientHandler&) = delete; + LSPS1ClientHandler(LSPS1ClientHandler&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1ClientHandler)); } + LSPS1ClientHandler(LDKLSPS1ClientHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1ClientHandler)); } + operator LDKLSPS1ClientHandler() && { LDKLSPS1ClientHandler res = self; memset(&self, 0, sizeof(LDKLSPS1ClientHandler)); return res; } + ~LSPS1ClientHandler() { LSPS1ClientHandler_free(self); } + LSPS1ClientHandler& operator=(LSPS1ClientHandler&& o) { LSPS1ClientHandler_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1ClientHandler)); return *this; } + LDKLSPS1ClientHandler* operator &() { return &self; } + LDKLSPS1ClientHandler* operator ->() { return &self; } + const LDKLSPS1ClientHandler* operator &() const { return &self; } + const LDKLSPS1ClientHandler* operator ->() const { return &self; } +}; +class LSPS2ClientConfig { +private: + LDKLSPS2ClientConfig self; +public: + LSPS2ClientConfig(const LSPS2ClientConfig&) = delete; + LSPS2ClientConfig(LSPS2ClientConfig&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2ClientConfig)); } + LSPS2ClientConfig(LDKLSPS2ClientConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2ClientConfig)); } + operator LDKLSPS2ClientConfig() && { LDKLSPS2ClientConfig res = self; memset(&self, 0, sizeof(LDKLSPS2ClientConfig)); return res; } + ~LSPS2ClientConfig() { LSPS2ClientConfig_free(self); } + LSPS2ClientConfig& operator=(LSPS2ClientConfig&& o) { LSPS2ClientConfig_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2ClientConfig)); return *this; } + LDKLSPS2ClientConfig* operator &() { return &self; } + LDKLSPS2ClientConfig* operator ->() { return &self; } + const LDKLSPS2ClientConfig* operator &() const { return &self; } + const LDKLSPS2ClientConfig* operator ->() const { return &self; } +}; +class LSPS2ClientHandler { +private: + LDKLSPS2ClientHandler self; +public: + LSPS2ClientHandler(const LSPS2ClientHandler&) = delete; + LSPS2ClientHandler(LSPS2ClientHandler&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2ClientHandler)); } + LSPS2ClientHandler(LDKLSPS2ClientHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2ClientHandler)); } + operator LDKLSPS2ClientHandler() && { LDKLSPS2ClientHandler res = self; memset(&self, 0, sizeof(LDKLSPS2ClientHandler)); return res; } + ~LSPS2ClientHandler() { LSPS2ClientHandler_free(self); } + LSPS2ClientHandler& operator=(LSPS2ClientHandler&& o) { LSPS2ClientHandler_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2ClientHandler)); return *this; } + LDKLSPS2ClientHandler* operator &() { return &self; } + LDKLSPS2ClientHandler* operator ->() { return &self; } + const LDKLSPS2ClientHandler* operator &() const { return &self; } + const LDKLSPS2ClientHandler* operator ->() const { return &self; } +}; +class LSPS2ClientEvent { +private: + LDKLSPS2ClientEvent self; +public: + LSPS2ClientEvent(const LSPS2ClientEvent&) = delete; + LSPS2ClientEvent(LSPS2ClientEvent&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2ClientEvent)); } + LSPS2ClientEvent(LDKLSPS2ClientEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2ClientEvent)); } + operator LDKLSPS2ClientEvent() && { LDKLSPS2ClientEvent res = self; memset(&self, 0, sizeof(LDKLSPS2ClientEvent)); return res; } + ~LSPS2ClientEvent() { LSPS2ClientEvent_free(self); } + LSPS2ClientEvent& operator=(LSPS2ClientEvent&& o) { LSPS2ClientEvent_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2ClientEvent)); return *this; } + LDKLSPS2ClientEvent* operator &() { return &self; } + LDKLSPS2ClientEvent* operator ->() { return &self; } + const LDKLSPS2ClientEvent* operator &() const { return &self; } + const LDKLSPS2ClientEvent* operator ->() const { return &self; } +}; +class LSPS2ServiceEvent { +private: + LDKLSPS2ServiceEvent self; +public: + LSPS2ServiceEvent(const LSPS2ServiceEvent&) = delete; + LSPS2ServiceEvent(LSPS2ServiceEvent&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2ServiceEvent)); } + LSPS2ServiceEvent(LDKLSPS2ServiceEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2ServiceEvent)); } + operator LDKLSPS2ServiceEvent() && { LDKLSPS2ServiceEvent res = self; memset(&self, 0, sizeof(LDKLSPS2ServiceEvent)); return res; } + ~LSPS2ServiceEvent() { LSPS2ServiceEvent_free(self); } + LSPS2ServiceEvent& operator=(LSPS2ServiceEvent&& o) { LSPS2ServiceEvent_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2ServiceEvent)); return *this; } + LDKLSPS2ServiceEvent* operator &() { return &self; } + LDKLSPS2ServiceEvent* operator ->() { return &self; } + const LDKLSPS2ServiceEvent* operator &() const { return &self; } + const LDKLSPS2ServiceEvent* operator ->() const { return &self; } +}; class OfferId { private: LDKOfferId self; @@ -3447,6 +3689,36 @@ class EcdsaChannelSigner { */ inline LDK::CResult_ECDSASignatureNoneZ sign_splicing_funding_input(struct LDKTransaction tx, uintptr_t input_index, uint64_t input_value); }; +class LSPS2ServiceConfig { +private: + LDKLSPS2ServiceConfig self; +public: + LSPS2ServiceConfig(const LSPS2ServiceConfig&) = delete; + LSPS2ServiceConfig(LSPS2ServiceConfig&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2ServiceConfig)); } + LSPS2ServiceConfig(LDKLSPS2ServiceConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2ServiceConfig)); } + operator LDKLSPS2ServiceConfig() && { LDKLSPS2ServiceConfig res = self; memset(&self, 0, sizeof(LDKLSPS2ServiceConfig)); return res; } + ~LSPS2ServiceConfig() { LSPS2ServiceConfig_free(self); } + LSPS2ServiceConfig& operator=(LSPS2ServiceConfig&& o) { LSPS2ServiceConfig_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2ServiceConfig)); return *this; } + LDKLSPS2ServiceConfig* operator &() { return &self; } + LDKLSPS2ServiceConfig* operator ->() { return &self; } + const LDKLSPS2ServiceConfig* operator &() const { return &self; } + const LDKLSPS2ServiceConfig* operator ->() const { return &self; } +}; +class LSPS2ServiceHandler { +private: + LDKLSPS2ServiceHandler self; +public: + LSPS2ServiceHandler(const LSPS2ServiceHandler&) = delete; + LSPS2ServiceHandler(LSPS2ServiceHandler&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2ServiceHandler)); } + LSPS2ServiceHandler(LDKLSPS2ServiceHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2ServiceHandler)); } + operator LDKLSPS2ServiceHandler() && { LDKLSPS2ServiceHandler res = self; memset(&self, 0, sizeof(LDKLSPS2ServiceHandler)); return res; } + ~LSPS2ServiceHandler() { LSPS2ServiceHandler_free(self); } + LSPS2ServiceHandler& operator=(LSPS2ServiceHandler&& o) { LSPS2ServiceHandler_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2ServiceHandler)); return *this; } + LDKLSPS2ServiceHandler* operator &() { return &self; } + LDKLSPS2ServiceHandler* operator ->() { return &self; } + const LDKLSPS2ServiceHandler* operator &() const { return &self; } + const LDKLSPS2ServiceHandler* operator ->() const { return &self; } +}; class ChannelMonitorUpdate { private: LDKChannelMonitorUpdate self; @@ -3587,6 +3859,8 @@ class CustomMessageHandler { * May return an `Err(())` if the features the peer supports are not sufficient to communicate * with us. Implementors should be somewhat conservative about doing so, however, as other * message handlers may still wish to communicate with this peer. + * + * [`Self::peer_disconnected`] will not be called if `Err(())` is returned. */ inline LDK::CResult_NoneNoneZ peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound); /** @@ -3775,6 +4049,21 @@ class RapidGossipSync { const LDKRapidGossipSync* operator &() const { return &self; } const LDKRapidGossipSync* operator ->() const { return &self; } }; +class LSPS1ClientEvent { +private: + LDKLSPS1ClientEvent self; +public: + LSPS1ClientEvent(const LSPS1ClientEvent&) = delete; + LSPS1ClientEvent(LSPS1ClientEvent&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1ClientEvent)); } + LSPS1ClientEvent(LDKLSPS1ClientEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1ClientEvent)); } + operator LDKLSPS1ClientEvent() && { LDKLSPS1ClientEvent res = self; memset(&self, 0, sizeof(LDKLSPS1ClientEvent)); return res; } + ~LSPS1ClientEvent() { LSPS1ClientEvent_free(self); } + LSPS1ClientEvent& operator=(LSPS1ClientEvent&& o) { LSPS1ClientEvent_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1ClientEvent)); return *this; } + LDKLSPS1ClientEvent* operator &() { return &self; } + LDKLSPS1ClientEvent* operator ->() { return &self; } + const LDKLSPS1ClientEvent* operator &() const { return &self; } + const LDKLSPS1ClientEvent* operator ->() const { return &self; } +}; class KVStore { private: LDKKVStore self; @@ -5057,6 +5346,8 @@ class ChannelMessageHandler { * May return an `Err(())` if the features the peer supports are not sufficient to communicate * with us. Implementors should be somewhat conservative about doing so, however, as other * message handlers may still wish to communicate with this peer. + * + * [`Self::peer_disconnected`] will not be called if `Err(())` is returned. */ inline LDK::CResult_NoneNoneZ peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound); /** @@ -5245,6 +5536,8 @@ class OnionMessageHandler { * May return an `Err(())` if the features the peer supports are not sufficient to communicate * with us. Implementors should be somewhat conservative about doing so, however, as other * message handlers may still wish to communicate with this peer. + * + * [`Self::peer_disconnected`] will not be called if `Err(())` is returned. */ inline LDK::CResult_NoneNoneZ peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init, bool inbound); /** @@ -5317,6 +5610,274 @@ class TrampolineOnionPacket { const LDKTrampolineOnionPacket* operator &() const { return &self; } const LDKTrampolineOnionPacket* operator ->() const { return &self; } }; +class LSPS1OrderId { +private: + LDKLSPS1OrderId self; +public: + LSPS1OrderId(const LSPS1OrderId&) = delete; + LSPS1OrderId(LSPS1OrderId&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1OrderId)); } + LSPS1OrderId(LDKLSPS1OrderId&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1OrderId)); } + operator LDKLSPS1OrderId() && { LDKLSPS1OrderId res = self; memset(&self, 0, sizeof(LDKLSPS1OrderId)); return res; } + ~LSPS1OrderId() { LSPS1OrderId_free(self); } + LSPS1OrderId& operator=(LSPS1OrderId&& o) { LSPS1OrderId_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1OrderId)); return *this; } + LDKLSPS1OrderId* operator &() { return &self; } + LDKLSPS1OrderId* operator ->() { return &self; } + const LDKLSPS1OrderId* operator &() const { return &self; } + const LDKLSPS1OrderId* operator ->() const { return &self; } +}; +class LSPS1GetInfoRequest { +private: + LDKLSPS1GetInfoRequest self; +public: + LSPS1GetInfoRequest(const LSPS1GetInfoRequest&) = delete; + LSPS1GetInfoRequest(LSPS1GetInfoRequest&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1GetInfoRequest)); } + LSPS1GetInfoRequest(LDKLSPS1GetInfoRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1GetInfoRequest)); } + operator LDKLSPS1GetInfoRequest() && { LDKLSPS1GetInfoRequest res = self; memset(&self, 0, sizeof(LDKLSPS1GetInfoRequest)); return res; } + ~LSPS1GetInfoRequest() { LSPS1GetInfoRequest_free(self); } + LSPS1GetInfoRequest& operator=(LSPS1GetInfoRequest&& o) { LSPS1GetInfoRequest_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1GetInfoRequest)); return *this; } + LDKLSPS1GetInfoRequest* operator &() { return &self; } + LDKLSPS1GetInfoRequest* operator ->() { return &self; } + const LDKLSPS1GetInfoRequest* operator &() const { return &self; } + const LDKLSPS1GetInfoRequest* operator ->() const { return &self; } +}; +class LSPS1Options { +private: + LDKLSPS1Options self; +public: + LSPS1Options(const LSPS1Options&) = delete; + LSPS1Options(LSPS1Options&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1Options)); } + LSPS1Options(LDKLSPS1Options&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1Options)); } + operator LDKLSPS1Options() && { LDKLSPS1Options res = self; memset(&self, 0, sizeof(LDKLSPS1Options)); return res; } + ~LSPS1Options() { LSPS1Options_free(self); } + LSPS1Options& operator=(LSPS1Options&& o) { LSPS1Options_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1Options)); return *this; } + LDKLSPS1Options* operator &() { return &self; } + LDKLSPS1Options* operator ->() { return &self; } + const LDKLSPS1Options* operator &() const { return &self; } + const LDKLSPS1Options* operator ->() const { return &self; } +}; +class LSPS1GetInfoResponse { +private: + LDKLSPS1GetInfoResponse self; +public: + LSPS1GetInfoResponse(const LSPS1GetInfoResponse&) = delete; + LSPS1GetInfoResponse(LSPS1GetInfoResponse&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1GetInfoResponse)); } + LSPS1GetInfoResponse(LDKLSPS1GetInfoResponse&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1GetInfoResponse)); } + operator LDKLSPS1GetInfoResponse() && { LDKLSPS1GetInfoResponse res = self; memset(&self, 0, sizeof(LDKLSPS1GetInfoResponse)); return res; } + ~LSPS1GetInfoResponse() { LSPS1GetInfoResponse_free(self); } + LSPS1GetInfoResponse& operator=(LSPS1GetInfoResponse&& o) { LSPS1GetInfoResponse_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1GetInfoResponse)); return *this; } + LDKLSPS1GetInfoResponse* operator &() { return &self; } + LDKLSPS1GetInfoResponse* operator ->() { return &self; } + const LDKLSPS1GetInfoResponse* operator &() const { return &self; } + const LDKLSPS1GetInfoResponse* operator ->() const { return &self; } +}; +class LSPS1CreateOrderRequest { +private: + LDKLSPS1CreateOrderRequest self; +public: + LSPS1CreateOrderRequest(const LSPS1CreateOrderRequest&) = delete; + LSPS1CreateOrderRequest(LSPS1CreateOrderRequest&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1CreateOrderRequest)); } + LSPS1CreateOrderRequest(LDKLSPS1CreateOrderRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1CreateOrderRequest)); } + operator LDKLSPS1CreateOrderRequest() && { LDKLSPS1CreateOrderRequest res = self; memset(&self, 0, sizeof(LDKLSPS1CreateOrderRequest)); return res; } + ~LSPS1CreateOrderRequest() { LSPS1CreateOrderRequest_free(self); } + LSPS1CreateOrderRequest& operator=(LSPS1CreateOrderRequest&& o) { LSPS1CreateOrderRequest_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1CreateOrderRequest)); return *this; } + LDKLSPS1CreateOrderRequest* operator &() { return &self; } + LDKLSPS1CreateOrderRequest* operator ->() { return &self; } + const LDKLSPS1CreateOrderRequest* operator &() const { return &self; } + const LDKLSPS1CreateOrderRequest* operator ->() const { return &self; } +}; +class LSPS1OrderParams { +private: + LDKLSPS1OrderParams self; +public: + LSPS1OrderParams(const LSPS1OrderParams&) = delete; + LSPS1OrderParams(LSPS1OrderParams&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1OrderParams)); } + LSPS1OrderParams(LDKLSPS1OrderParams&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1OrderParams)); } + operator LDKLSPS1OrderParams() && { LDKLSPS1OrderParams res = self; memset(&self, 0, sizeof(LDKLSPS1OrderParams)); return res; } + ~LSPS1OrderParams() { LSPS1OrderParams_free(self); } + LSPS1OrderParams& operator=(LSPS1OrderParams&& o) { LSPS1OrderParams_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1OrderParams)); return *this; } + LDKLSPS1OrderParams* operator &() { return &self; } + LDKLSPS1OrderParams* operator ->() { return &self; } + const LDKLSPS1OrderParams* operator &() const { return &self; } + const LDKLSPS1OrderParams* operator ->() const { return &self; } +}; +class LSPS1CreateOrderResponse { +private: + LDKLSPS1CreateOrderResponse self; +public: + LSPS1CreateOrderResponse(const LSPS1CreateOrderResponse&) = delete; + LSPS1CreateOrderResponse(LSPS1CreateOrderResponse&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1CreateOrderResponse)); } + LSPS1CreateOrderResponse(LDKLSPS1CreateOrderResponse&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1CreateOrderResponse)); } + operator LDKLSPS1CreateOrderResponse() && { LDKLSPS1CreateOrderResponse res = self; memset(&self, 0, sizeof(LDKLSPS1CreateOrderResponse)); return res; } + ~LSPS1CreateOrderResponse() { LSPS1CreateOrderResponse_free(self); } + LSPS1CreateOrderResponse& operator=(LSPS1CreateOrderResponse&& o) { LSPS1CreateOrderResponse_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1CreateOrderResponse)); return *this; } + LDKLSPS1CreateOrderResponse* operator &() { return &self; } + LDKLSPS1CreateOrderResponse* operator ->() { return &self; } + const LDKLSPS1CreateOrderResponse* operator &() const { return &self; } + const LDKLSPS1CreateOrderResponse* operator ->() const { return &self; } +}; +class LSPS1OrderState { +private: + LDKLSPS1OrderState self; +public: + LSPS1OrderState(const LSPS1OrderState&) = delete; + LSPS1OrderState(LSPS1OrderState&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1OrderState)); } + LSPS1OrderState(LDKLSPS1OrderState&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1OrderState)); } + operator LDKLSPS1OrderState() && { LDKLSPS1OrderState res = self; memset(&self, 0, sizeof(LDKLSPS1OrderState)); return res; } + LSPS1OrderState& operator=(LSPS1OrderState&& o) { self = o.self; memset(&o, 0, sizeof(LSPS1OrderState)); return *this; } + LDKLSPS1OrderState* operator &() { return &self; } + LDKLSPS1OrderState* operator ->() { return &self; } + const LDKLSPS1OrderState* operator &() const { return &self; } + const LDKLSPS1OrderState* operator ->() const { return &self; } +}; +class LSPS1PaymentInfo { +private: + LDKLSPS1PaymentInfo self; +public: + LSPS1PaymentInfo(const LSPS1PaymentInfo&) = delete; + LSPS1PaymentInfo(LSPS1PaymentInfo&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1PaymentInfo)); } + LSPS1PaymentInfo(LDKLSPS1PaymentInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1PaymentInfo)); } + operator LDKLSPS1PaymentInfo() && { LDKLSPS1PaymentInfo res = self; memset(&self, 0, sizeof(LDKLSPS1PaymentInfo)); return res; } + ~LSPS1PaymentInfo() { LSPS1PaymentInfo_free(self); } + LSPS1PaymentInfo& operator=(LSPS1PaymentInfo&& o) { LSPS1PaymentInfo_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1PaymentInfo)); return *this; } + LDKLSPS1PaymentInfo* operator &() { return &self; } + LDKLSPS1PaymentInfo* operator ->() { return &self; } + const LDKLSPS1PaymentInfo* operator &() const { return &self; } + const LDKLSPS1PaymentInfo* operator ->() const { return &self; } +}; +class LSPS1Bolt11PaymentInfo { +private: + LDKLSPS1Bolt11PaymentInfo self; +public: + LSPS1Bolt11PaymentInfo(const LSPS1Bolt11PaymentInfo&) = delete; + LSPS1Bolt11PaymentInfo(LSPS1Bolt11PaymentInfo&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1Bolt11PaymentInfo)); } + LSPS1Bolt11PaymentInfo(LDKLSPS1Bolt11PaymentInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1Bolt11PaymentInfo)); } + operator LDKLSPS1Bolt11PaymentInfo() && { LDKLSPS1Bolt11PaymentInfo res = self; memset(&self, 0, sizeof(LDKLSPS1Bolt11PaymentInfo)); return res; } + ~LSPS1Bolt11PaymentInfo() { LSPS1Bolt11PaymentInfo_free(self); } + LSPS1Bolt11PaymentInfo& operator=(LSPS1Bolt11PaymentInfo&& o) { LSPS1Bolt11PaymentInfo_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1Bolt11PaymentInfo)); return *this; } + LDKLSPS1Bolt11PaymentInfo* operator &() { return &self; } + LDKLSPS1Bolt11PaymentInfo* operator ->() { return &self; } + const LDKLSPS1Bolt11PaymentInfo* operator &() const { return &self; } + const LDKLSPS1Bolt11PaymentInfo* operator ->() const { return &self; } +}; +class LSPS1OnchainPaymentInfo { +private: + LDKLSPS1OnchainPaymentInfo self; +public: + LSPS1OnchainPaymentInfo(const LSPS1OnchainPaymentInfo&) = delete; + LSPS1OnchainPaymentInfo(LSPS1OnchainPaymentInfo&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1OnchainPaymentInfo)); } + LSPS1OnchainPaymentInfo(LDKLSPS1OnchainPaymentInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1OnchainPaymentInfo)); } + operator LDKLSPS1OnchainPaymentInfo() && { LDKLSPS1OnchainPaymentInfo res = self; memset(&self, 0, sizeof(LDKLSPS1OnchainPaymentInfo)); return res; } + ~LSPS1OnchainPaymentInfo() { LSPS1OnchainPaymentInfo_free(self); } + LSPS1OnchainPaymentInfo& operator=(LSPS1OnchainPaymentInfo&& o) { LSPS1OnchainPaymentInfo_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1OnchainPaymentInfo)); return *this; } + LDKLSPS1OnchainPaymentInfo* operator &() { return &self; } + LDKLSPS1OnchainPaymentInfo* operator ->() { return &self; } + const LDKLSPS1OnchainPaymentInfo* operator &() const { return &self; } + const LDKLSPS1OnchainPaymentInfo* operator ->() const { return &self; } +}; +class LSPS1PaymentState { +private: + LDKLSPS1PaymentState self; +public: + LSPS1PaymentState(const LSPS1PaymentState&) = delete; + LSPS1PaymentState(LSPS1PaymentState&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1PaymentState)); } + LSPS1PaymentState(LDKLSPS1PaymentState&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1PaymentState)); } + operator LDKLSPS1PaymentState() && { LDKLSPS1PaymentState res = self; memset(&self, 0, sizeof(LDKLSPS1PaymentState)); return res; } + LSPS1PaymentState& operator=(LSPS1PaymentState&& o) { self = o.self; memset(&o, 0, sizeof(LSPS1PaymentState)); return *this; } + LDKLSPS1PaymentState* operator &() { return &self; } + LDKLSPS1PaymentState* operator ->() { return &self; } + const LDKLSPS1PaymentState* operator &() const { return &self; } + const LDKLSPS1PaymentState* operator ->() const { return &self; } +}; +class LSPS1OnchainPayment { +private: + LDKLSPS1OnchainPayment self; +public: + LSPS1OnchainPayment(const LSPS1OnchainPayment&) = delete; + LSPS1OnchainPayment(LSPS1OnchainPayment&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1OnchainPayment)); } + LSPS1OnchainPayment(LDKLSPS1OnchainPayment&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1OnchainPayment)); } + operator LDKLSPS1OnchainPayment() && { LDKLSPS1OnchainPayment res = self; memset(&self, 0, sizeof(LDKLSPS1OnchainPayment)); return res; } + ~LSPS1OnchainPayment() { LSPS1OnchainPayment_free(self); } + LSPS1OnchainPayment& operator=(LSPS1OnchainPayment&& o) { LSPS1OnchainPayment_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1OnchainPayment)); return *this; } + LDKLSPS1OnchainPayment* operator &() { return &self; } + LDKLSPS1OnchainPayment* operator ->() { return &self; } + const LDKLSPS1OnchainPayment* operator &() const { return &self; } + const LDKLSPS1OnchainPayment* operator ->() const { return &self; } +}; +class LSPS1ChannelInfo { +private: + LDKLSPS1ChannelInfo self; +public: + LSPS1ChannelInfo(const LSPS1ChannelInfo&) = delete; + LSPS1ChannelInfo(LSPS1ChannelInfo&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1ChannelInfo)); } + LSPS1ChannelInfo(LDKLSPS1ChannelInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1ChannelInfo)); } + operator LDKLSPS1ChannelInfo() && { LDKLSPS1ChannelInfo res = self; memset(&self, 0, sizeof(LDKLSPS1ChannelInfo)); return res; } + ~LSPS1ChannelInfo() { LSPS1ChannelInfo_free(self); } + LSPS1ChannelInfo& operator=(LSPS1ChannelInfo&& o) { LSPS1ChannelInfo_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1ChannelInfo)); return *this; } + LDKLSPS1ChannelInfo* operator &() { return &self; } + LDKLSPS1ChannelInfo* operator ->() { return &self; } + const LDKLSPS1ChannelInfo* operator &() const { return &self; } + const LDKLSPS1ChannelInfo* operator ->() const { return &self; } +}; +class LSPS1GetOrderRequest { +private: + LDKLSPS1GetOrderRequest self; +public: + LSPS1GetOrderRequest(const LSPS1GetOrderRequest&) = delete; + LSPS1GetOrderRequest(LSPS1GetOrderRequest&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1GetOrderRequest)); } + LSPS1GetOrderRequest(LDKLSPS1GetOrderRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1GetOrderRequest)); } + operator LDKLSPS1GetOrderRequest() && { LDKLSPS1GetOrderRequest res = self; memset(&self, 0, sizeof(LDKLSPS1GetOrderRequest)); return res; } + ~LSPS1GetOrderRequest() { LSPS1GetOrderRequest_free(self); } + LSPS1GetOrderRequest& operator=(LSPS1GetOrderRequest&& o) { LSPS1GetOrderRequest_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1GetOrderRequest)); return *this; } + LDKLSPS1GetOrderRequest* operator &() { return &self; } + LDKLSPS1GetOrderRequest* operator ->() { return &self; } + const LDKLSPS1GetOrderRequest* operator &() const { return &self; } + const LDKLSPS1GetOrderRequest* operator ->() const { return &self; } +}; +class LSPS1Request { +private: + LDKLSPS1Request self; +public: + LSPS1Request(const LSPS1Request&) = delete; + LSPS1Request(LSPS1Request&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1Request)); } + LSPS1Request(LDKLSPS1Request&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1Request)); } + operator LDKLSPS1Request() && { LDKLSPS1Request res = self; memset(&self, 0, sizeof(LDKLSPS1Request)); return res; } + ~LSPS1Request() { LSPS1Request_free(self); } + LSPS1Request& operator=(LSPS1Request&& o) { LSPS1Request_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1Request)); return *this; } + LDKLSPS1Request* operator &() { return &self; } + LDKLSPS1Request* operator ->() { return &self; } + const LDKLSPS1Request* operator &() const { return &self; } + const LDKLSPS1Request* operator ->() const { return &self; } +}; +class LSPS1Response { +private: + LDKLSPS1Response self; +public: + LSPS1Response(const LSPS1Response&) = delete; + LSPS1Response(LSPS1Response&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1Response)); } + LSPS1Response(LDKLSPS1Response&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1Response)); } + operator LDKLSPS1Response() && { LDKLSPS1Response res = self; memset(&self, 0, sizeof(LDKLSPS1Response)); return res; } + ~LSPS1Response() { LSPS1Response_free(self); } + LSPS1Response& operator=(LSPS1Response&& o) { LSPS1Response_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1Response)); return *this; } + LDKLSPS1Response* operator &() { return &self; } + LDKLSPS1Response* operator ->() { return &self; } + const LDKLSPS1Response* operator &() const { return &self; } + const LDKLSPS1Response* operator ->() const { return &self; } +}; +class LSPS1Message { +private: + LDKLSPS1Message self; +public: + LSPS1Message(const LSPS1Message&) = delete; + LSPS1Message(LSPS1Message&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS1Message)); } + LSPS1Message(LDKLSPS1Message&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS1Message)); } + operator LDKLSPS1Message() && { LDKLSPS1Message res = self; memset(&self, 0, sizeof(LDKLSPS1Message)); return res; } + ~LSPS1Message() { LSPS1Message_free(self); } + LSPS1Message& operator=(LSPS1Message&& o) { LSPS1Message_free(self); self = o.self; memset(&o, 0, sizeof(LSPS1Message)); return *this; } + LDKLSPS1Message* operator &() { return &self; } + LDKLSPS1Message* operator ->() { return &self; } + const LDKLSPS1Message* operator &() const { return &self; } + const LDKLSPS1Message* operator ->() const { return &self; } +}; class Level { private: LDKLevel self; @@ -5531,6 +6092,81 @@ class Sleeper { const LDKSleeper* operator &() const { return &self; } const LDKSleeper* operator ->() const { return &self; } }; +class RawLSPSMessage { +private: + LDKRawLSPSMessage self; +public: + RawLSPSMessage(const RawLSPSMessage&) = delete; + RawLSPSMessage(RawLSPSMessage&& o) : self(o.self) { memset(&o, 0, sizeof(RawLSPSMessage)); } + RawLSPSMessage(LDKRawLSPSMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawLSPSMessage)); } + operator LDKRawLSPSMessage() && { LDKRawLSPSMessage res = self; memset(&self, 0, sizeof(LDKRawLSPSMessage)); return res; } + ~RawLSPSMessage() { RawLSPSMessage_free(self); } + RawLSPSMessage& operator=(RawLSPSMessage&& o) { RawLSPSMessage_free(self); self = o.self; memset(&o, 0, sizeof(RawLSPSMessage)); return *this; } + LDKRawLSPSMessage* operator &() { return &self; } + LDKRawLSPSMessage* operator ->() { return &self; } + const LDKRawLSPSMessage* operator &() const { return &self; } + const LDKRawLSPSMessage* operator ->() const { return &self; } +}; +class LSPSRequestId { +private: + LDKLSPSRequestId self; +public: + LSPSRequestId(const LSPSRequestId&) = delete; + LSPSRequestId(LSPSRequestId&& o) : self(o.self) { memset(&o, 0, sizeof(LSPSRequestId)); } + LSPSRequestId(LDKLSPSRequestId&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPSRequestId)); } + operator LDKLSPSRequestId() && { LDKLSPSRequestId res = self; memset(&self, 0, sizeof(LDKLSPSRequestId)); return res; } + ~LSPSRequestId() { LSPSRequestId_free(self); } + LSPSRequestId& operator=(LSPSRequestId&& o) { LSPSRequestId_free(self); self = o.self; memset(&o, 0, sizeof(LSPSRequestId)); return *this; } + LDKLSPSRequestId* operator &() { return &self; } + LDKLSPSRequestId* operator ->() { return &self; } + const LDKLSPSRequestId* operator &() const { return &self; } + const LDKLSPSRequestId* operator ->() const { return &self; } +}; +class LSPSDateTime { +private: + LDKLSPSDateTime self; +public: + LSPSDateTime(const LSPSDateTime&) = delete; + LSPSDateTime(LSPSDateTime&& o) : self(o.self) { memset(&o, 0, sizeof(LSPSDateTime)); } + LSPSDateTime(LDKLSPSDateTime&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPSDateTime)); } + operator LDKLSPSDateTime() && { LDKLSPSDateTime res = self; memset(&self, 0, sizeof(LDKLSPSDateTime)); return res; } + ~LSPSDateTime() { LSPSDateTime_free(self); } + LSPSDateTime& operator=(LSPSDateTime&& o) { LSPSDateTime_free(self); self = o.self; memset(&o, 0, sizeof(LSPSDateTime)); return *this; } + LDKLSPSDateTime* operator &() { return &self; } + LDKLSPSDateTime* operator ->() { return &self; } + const LDKLSPSDateTime* operator &() const { return &self; } + const LDKLSPSDateTime* operator ->() const { return &self; } +}; +class LSPSResponseError { +private: + LDKLSPSResponseError self; +public: + LSPSResponseError(const LSPSResponseError&) = delete; + LSPSResponseError(LSPSResponseError&& o) : self(o.self) { memset(&o, 0, sizeof(LSPSResponseError)); } + LSPSResponseError(LDKLSPSResponseError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPSResponseError)); } + operator LDKLSPSResponseError() && { LDKLSPSResponseError res = self; memset(&self, 0, sizeof(LDKLSPSResponseError)); return res; } + ~LSPSResponseError() { LSPSResponseError_free(self); } + LSPSResponseError& operator=(LSPSResponseError&& o) { LSPSResponseError_free(self); self = o.self; memset(&o, 0, sizeof(LSPSResponseError)); return *this; } + LDKLSPSResponseError* operator &() { return &self; } + LDKLSPSResponseError* operator ->() { return &self; } + const LDKLSPSResponseError* operator &() const { return &self; } + const LDKLSPSResponseError* operator ->() const { return &self; } +}; +class LSPSMessage { +private: + LDKLSPSMessage self; +public: + LSPSMessage(const LSPSMessage&) = delete; + LSPSMessage(LSPSMessage&& o) : self(o.self) { memset(&o, 0, sizeof(LSPSMessage)); } + LSPSMessage(LDKLSPSMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPSMessage)); } + operator LDKLSPSMessage() && { LDKLSPSMessage res = self; memset(&self, 0, sizeof(LDKLSPSMessage)); return res; } + ~LSPSMessage() { LSPSMessage_free(self); } + LSPSMessage& operator=(LSPSMessage&& o) { LSPSMessage_free(self); self = o.self; memset(&o, 0, sizeof(LSPSMessage)); return *this; } + LDKLSPSMessage* operator &() { return &self; } + LDKLSPSMessage* operator ->() { return &self; } + const LDKLSPSMessage* operator &() const { return &self; } + const LDKLSPSMessage* operator ->() const { return &self; } +}; class AsyncPaymentsMessageHandler { private: LDKAsyncPaymentsMessageHandler self; @@ -5997,6 +6633,156 @@ class FeeEstimator { */ inline uint32_t get_est_sat_per_1000_weight(enum LDKConfirmationTarget confirmation_target); }; +class LSPS2GetInfoRequest { +private: + LDKLSPS2GetInfoRequest self; +public: + LSPS2GetInfoRequest(const LSPS2GetInfoRequest&) = delete; + LSPS2GetInfoRequest(LSPS2GetInfoRequest&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2GetInfoRequest)); } + LSPS2GetInfoRequest(LDKLSPS2GetInfoRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2GetInfoRequest)); } + operator LDKLSPS2GetInfoRequest() && { LDKLSPS2GetInfoRequest res = self; memset(&self, 0, sizeof(LDKLSPS2GetInfoRequest)); return res; } + ~LSPS2GetInfoRequest() { LSPS2GetInfoRequest_free(self); } + LSPS2GetInfoRequest& operator=(LSPS2GetInfoRequest&& o) { LSPS2GetInfoRequest_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2GetInfoRequest)); return *this; } + LDKLSPS2GetInfoRequest* operator &() { return &self; } + LDKLSPS2GetInfoRequest* operator ->() { return &self; } + const LDKLSPS2GetInfoRequest* operator &() const { return &self; } + const LDKLSPS2GetInfoRequest* operator ->() const { return &self; } +}; +class LSPS2RawOpeningFeeParams { +private: + LDKLSPS2RawOpeningFeeParams self; +public: + LSPS2RawOpeningFeeParams(const LSPS2RawOpeningFeeParams&) = delete; + LSPS2RawOpeningFeeParams(LSPS2RawOpeningFeeParams&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2RawOpeningFeeParams)); } + LSPS2RawOpeningFeeParams(LDKLSPS2RawOpeningFeeParams&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2RawOpeningFeeParams)); } + operator LDKLSPS2RawOpeningFeeParams() && { LDKLSPS2RawOpeningFeeParams res = self; memset(&self, 0, sizeof(LDKLSPS2RawOpeningFeeParams)); return res; } + ~LSPS2RawOpeningFeeParams() { LSPS2RawOpeningFeeParams_free(self); } + LSPS2RawOpeningFeeParams& operator=(LSPS2RawOpeningFeeParams&& o) { LSPS2RawOpeningFeeParams_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2RawOpeningFeeParams)); return *this; } + LDKLSPS2RawOpeningFeeParams* operator &() { return &self; } + LDKLSPS2RawOpeningFeeParams* operator ->() { return &self; } + const LDKLSPS2RawOpeningFeeParams* operator &() const { return &self; } + const LDKLSPS2RawOpeningFeeParams* operator ->() const { return &self; } +}; +class LSPS2OpeningFeeParams { +private: + LDKLSPS2OpeningFeeParams self; +public: + LSPS2OpeningFeeParams(const LSPS2OpeningFeeParams&) = delete; + LSPS2OpeningFeeParams(LSPS2OpeningFeeParams&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2OpeningFeeParams)); } + LSPS2OpeningFeeParams(LDKLSPS2OpeningFeeParams&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2OpeningFeeParams)); } + operator LDKLSPS2OpeningFeeParams() && { LDKLSPS2OpeningFeeParams res = self; memset(&self, 0, sizeof(LDKLSPS2OpeningFeeParams)); return res; } + ~LSPS2OpeningFeeParams() { LSPS2OpeningFeeParams_free(self); } + LSPS2OpeningFeeParams& operator=(LSPS2OpeningFeeParams&& o) { LSPS2OpeningFeeParams_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2OpeningFeeParams)); return *this; } + LDKLSPS2OpeningFeeParams* operator &() { return &self; } + LDKLSPS2OpeningFeeParams* operator ->() { return &self; } + const LDKLSPS2OpeningFeeParams* operator &() const { return &self; } + const LDKLSPS2OpeningFeeParams* operator ->() const { return &self; } +}; +class LSPS2GetInfoResponse { +private: + LDKLSPS2GetInfoResponse self; +public: + LSPS2GetInfoResponse(const LSPS2GetInfoResponse&) = delete; + LSPS2GetInfoResponse(LSPS2GetInfoResponse&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2GetInfoResponse)); } + LSPS2GetInfoResponse(LDKLSPS2GetInfoResponse&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2GetInfoResponse)); } + operator LDKLSPS2GetInfoResponse() && { LDKLSPS2GetInfoResponse res = self; memset(&self, 0, sizeof(LDKLSPS2GetInfoResponse)); return res; } + ~LSPS2GetInfoResponse() { LSPS2GetInfoResponse_free(self); } + LSPS2GetInfoResponse& operator=(LSPS2GetInfoResponse&& o) { LSPS2GetInfoResponse_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2GetInfoResponse)); return *this; } + LDKLSPS2GetInfoResponse* operator &() { return &self; } + LDKLSPS2GetInfoResponse* operator ->() { return &self; } + const LDKLSPS2GetInfoResponse* operator &() const { return &self; } + const LDKLSPS2GetInfoResponse* operator ->() const { return &self; } +}; +class LSPS2BuyRequest { +private: + LDKLSPS2BuyRequest self; +public: + LSPS2BuyRequest(const LSPS2BuyRequest&) = delete; + LSPS2BuyRequest(LSPS2BuyRequest&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2BuyRequest)); } + LSPS2BuyRequest(LDKLSPS2BuyRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2BuyRequest)); } + operator LDKLSPS2BuyRequest() && { LDKLSPS2BuyRequest res = self; memset(&self, 0, sizeof(LDKLSPS2BuyRequest)); return res; } + ~LSPS2BuyRequest() { LSPS2BuyRequest_free(self); } + LSPS2BuyRequest& operator=(LSPS2BuyRequest&& o) { LSPS2BuyRequest_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2BuyRequest)); return *this; } + LDKLSPS2BuyRequest* operator &() { return &self; } + LDKLSPS2BuyRequest* operator ->() { return &self; } + const LDKLSPS2BuyRequest* operator &() const { return &self; } + const LDKLSPS2BuyRequest* operator ->() const { return &self; } +}; +class LSPS2InterceptScid { +private: + LDKLSPS2InterceptScid self; +public: + LSPS2InterceptScid(const LSPS2InterceptScid&) = delete; + LSPS2InterceptScid(LSPS2InterceptScid&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2InterceptScid)); } + LSPS2InterceptScid(LDKLSPS2InterceptScid&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2InterceptScid)); } + operator LDKLSPS2InterceptScid() && { LDKLSPS2InterceptScid res = self; memset(&self, 0, sizeof(LDKLSPS2InterceptScid)); return res; } + ~LSPS2InterceptScid() { LSPS2InterceptScid_free(self); } + LSPS2InterceptScid& operator=(LSPS2InterceptScid&& o) { LSPS2InterceptScid_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2InterceptScid)); return *this; } + LDKLSPS2InterceptScid* operator &() { return &self; } + LDKLSPS2InterceptScid* operator ->() { return &self; } + const LDKLSPS2InterceptScid* operator &() const { return &self; } + const LDKLSPS2InterceptScid* operator ->() const { return &self; } +}; +class LSPS2BuyResponse { +private: + LDKLSPS2BuyResponse self; +public: + LSPS2BuyResponse(const LSPS2BuyResponse&) = delete; + LSPS2BuyResponse(LSPS2BuyResponse&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2BuyResponse)); } + LSPS2BuyResponse(LDKLSPS2BuyResponse&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2BuyResponse)); } + operator LDKLSPS2BuyResponse() && { LDKLSPS2BuyResponse res = self; memset(&self, 0, sizeof(LDKLSPS2BuyResponse)); return res; } + ~LSPS2BuyResponse() { LSPS2BuyResponse_free(self); } + LSPS2BuyResponse& operator=(LSPS2BuyResponse&& o) { LSPS2BuyResponse_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2BuyResponse)); return *this; } + LDKLSPS2BuyResponse* operator &() { return &self; } + LDKLSPS2BuyResponse* operator ->() { return &self; } + const LDKLSPS2BuyResponse* operator &() const { return &self; } + const LDKLSPS2BuyResponse* operator ->() const { return &self; } +}; +class LSPS2Request { +private: + LDKLSPS2Request self; +public: + LSPS2Request(const LSPS2Request&) = delete; + LSPS2Request(LSPS2Request&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2Request)); } + LSPS2Request(LDKLSPS2Request&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2Request)); } + operator LDKLSPS2Request() && { LDKLSPS2Request res = self; memset(&self, 0, sizeof(LDKLSPS2Request)); return res; } + ~LSPS2Request() { LSPS2Request_free(self); } + LSPS2Request& operator=(LSPS2Request&& o) { LSPS2Request_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2Request)); return *this; } + LDKLSPS2Request* operator &() { return &self; } + LDKLSPS2Request* operator ->() { return &self; } + const LDKLSPS2Request* operator &() const { return &self; } + const LDKLSPS2Request* operator ->() const { return &self; } +}; +class LSPS2Response { +private: + LDKLSPS2Response self; +public: + LSPS2Response(const LSPS2Response&) = delete; + LSPS2Response(LSPS2Response&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2Response)); } + LSPS2Response(LDKLSPS2Response&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2Response)); } + operator LDKLSPS2Response() && { LDKLSPS2Response res = self; memset(&self, 0, sizeof(LDKLSPS2Response)); return res; } + ~LSPS2Response() { LSPS2Response_free(self); } + LSPS2Response& operator=(LSPS2Response&& o) { LSPS2Response_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2Response)); return *this; } + LDKLSPS2Response* operator &() { return &self; } + LDKLSPS2Response* operator ->() { return &self; } + const LDKLSPS2Response* operator &() const { return &self; } + const LDKLSPS2Response* operator ->() const { return &self; } +}; +class LSPS2Message { +private: + LDKLSPS2Message self; +public: + LSPS2Message(const LSPS2Message&) = delete; + LSPS2Message(LSPS2Message&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS2Message)); } + LSPS2Message(LDKLSPS2Message&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS2Message)); } + operator LDKLSPS2Message() && { LDKLSPS2Message res = self; memset(&self, 0, sizeof(LDKLSPS2Message)); return res; } + ~LSPS2Message() { LSPS2Message_free(self); } + LSPS2Message& operator=(LSPS2Message&& o) { LSPS2Message_free(self); self = o.self; memset(&o, 0, sizeof(LSPS2Message)); return *this; } + LDKLSPS2Message* operator &() { return &self; } + LDKLSPS2Message* operator ->() { return &self; } + const LDKLSPS2Message* operator &() const { return &self; } + const LDKLSPS2Message* operator ->() const { return &self; } +}; class Packet { private: LDKPacket self; @@ -6936,6 +7722,21 @@ class Bolt12RefundContext { const LDKBolt12RefundContext* operator &() const { return &self; } const LDKBolt12RefundContext* operator ->() const { return &self; } }; +class LSPS0ClientEvent { +private: + LDKLSPS0ClientEvent self; +public: + LSPS0ClientEvent(const LSPS0ClientEvent&) = delete; + LSPS0ClientEvent(LSPS0ClientEvent&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS0ClientEvent)); } + LSPS0ClientEvent(LDKLSPS0ClientEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS0ClientEvent)); } + operator LDKLSPS0ClientEvent() && { LDKLSPS0ClientEvent res = self; memset(&self, 0, sizeof(LDKLSPS0ClientEvent)); return res; } + ~LSPS0ClientEvent() { LSPS0ClientEvent_free(self); } + LSPS0ClientEvent& operator=(LSPS0ClientEvent&& o) { LSPS0ClientEvent_free(self); self = o.self; memset(&o, 0, sizeof(LSPS0ClientEvent)); return *this; } + LDKLSPS0ClientEvent* operator &() { return &self; } + LDKLSPS0ClientEvent* operator ->() { return &self; } + const LDKLSPS0ClientEvent* operator &() const { return &self; } + const LDKLSPS0ClientEvent* operator ->() const { return &self; } +}; class UtxoLookupError { private: LDKUtxoLookupError self; @@ -7463,6 +8264,55 @@ class BlindedHop { const LDKBlindedHop* operator &() const { return &self; } const LDKBlindedHop* operator ->() const { return &self; } }; +class LiquidityEvent { +private: + LDKLiquidityEvent self; +public: + LiquidityEvent(const LiquidityEvent&) = delete; + LiquidityEvent(LiquidityEvent&& o) : self(o.self) { memset(&o, 0, sizeof(LiquidityEvent)); } + LiquidityEvent(LDKLiquidityEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLiquidityEvent)); } + operator LDKLiquidityEvent() && { LDKLiquidityEvent res = self; memset(&self, 0, sizeof(LDKLiquidityEvent)); return res; } + ~LiquidityEvent() { LiquidityEvent_free(self); } + LiquidityEvent& operator=(LiquidityEvent&& o) { LiquidityEvent_free(self); self = o.self; memset(&o, 0, sizeof(LiquidityEvent)); return *this; } + LDKLiquidityEvent* operator &() { return &self; } + LDKLiquidityEvent* operator ->() { return &self; } + const LDKLiquidityEvent* operator &() const { return &self; } + const LDKLiquidityEvent* operator ->() const { return &self; } +}; +class MessageQueue { +private: + LDKMessageQueue self; +public: + MessageQueue(const MessageQueue&) = delete; + MessageQueue(MessageQueue&& o) : self(o.self) { memset(&o, 0, sizeof(MessageQueue)); } + MessageQueue(LDKMessageQueue&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageQueue)); } + operator LDKMessageQueue() && { LDKMessageQueue res = self; memset(&self, 0, sizeof(LDKMessageQueue)); return res; } + ~MessageQueue() { MessageQueue_free(self); } + MessageQueue& operator=(MessageQueue&& o) { MessageQueue_free(self); self = o.self; memset(&o, 0, sizeof(MessageQueue)); return *this; } + LDKMessageQueue* operator &() { return &self; } + LDKMessageQueue* operator ->() { return &self; } + const LDKMessageQueue* operator &() const { return &self; } + const LDKMessageQueue* operator ->() const { return &self; } +}; +class ProcessMessagesCallback { +private: + LDKProcessMessagesCallback self; +public: + ProcessMessagesCallback(const ProcessMessagesCallback&) = delete; + ProcessMessagesCallback(ProcessMessagesCallback&& o) : self(o.self) { memset(&o, 0, sizeof(ProcessMessagesCallback)); } + ProcessMessagesCallback(LDKProcessMessagesCallback&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKProcessMessagesCallback)); } + operator LDKProcessMessagesCallback() && { LDKProcessMessagesCallback res = self; memset(&self, 0, sizeof(LDKProcessMessagesCallback)); return res; } + ~ProcessMessagesCallback() { ProcessMessagesCallback_free(self); } + ProcessMessagesCallback& operator=(ProcessMessagesCallback&& o) { ProcessMessagesCallback_free(self); self = o.self; memset(&o, 0, sizeof(ProcessMessagesCallback)); return *this; } + LDKProcessMessagesCallback* operator &() { return &self; } + LDKProcessMessagesCallback* operator ->() { return &self; } + const LDKProcessMessagesCallback* operator &() const { return &self; } + const LDKProcessMessagesCallback* operator ->() const { return &self; } + /** + * The method which is called. + */ + inline void call(); +}; class InvoiceError { private: LDKInvoiceError self; @@ -7763,6 +8613,21 @@ class ChainMonitor { const LDKChainMonitor* operator &() const { return &self; } const LDKChainMonitor* operator ->() const { return &self; } }; +class LSPS0ServiceHandler { +private: + LDKLSPS0ServiceHandler self; +public: + LSPS0ServiceHandler(const LSPS0ServiceHandler&) = delete; + LSPS0ServiceHandler(LSPS0ServiceHandler&& o) : self(o.self) { memset(&o, 0, sizeof(LSPS0ServiceHandler)); } + LSPS0ServiceHandler(LDKLSPS0ServiceHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLSPS0ServiceHandler)); } + operator LDKLSPS0ServiceHandler() && { LDKLSPS0ServiceHandler res = self; memset(&self, 0, sizeof(LDKLSPS0ServiceHandler)); return res; } + ~LSPS0ServiceHandler() { LSPS0ServiceHandler_free(self); } + LSPS0ServiceHandler& operator=(LSPS0ServiceHandler&& o) { LSPS0ServiceHandler_free(self); self = o.self; memset(&o, 0, sizeof(LSPS0ServiceHandler)); return *this; } + LDKLSPS0ServiceHandler* operator &() { return &self; } + LDKLSPS0ServiceHandler* operator ->() { return &self; } + const LDKLSPS0ServiceHandler* operator &() const { return &self; } + const LDKLSPS0ServiceHandler* operator ->() const { return &self; } +}; class BlindedMessagePath { private: LDKBlindedMessagePath self; @@ -9563,6 +10428,21 @@ class CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { const LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* operator &() const { return &self; } const LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_LSPSRequestIdAPIErrorZ { +private: + LDKCResult_LSPSRequestIdAPIErrorZ self; +public: + CResult_LSPSRequestIdAPIErrorZ(const CResult_LSPSRequestIdAPIErrorZ&) = delete; + CResult_LSPSRequestIdAPIErrorZ(CResult_LSPSRequestIdAPIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_LSPSRequestIdAPIErrorZ)); } + CResult_LSPSRequestIdAPIErrorZ(LDKCResult_LSPSRequestIdAPIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_LSPSRequestIdAPIErrorZ)); } + operator LDKCResult_LSPSRequestIdAPIErrorZ() && { LDKCResult_LSPSRequestIdAPIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_LSPSRequestIdAPIErrorZ)); return res; } + ~CResult_LSPSRequestIdAPIErrorZ() { CResult_LSPSRequestIdAPIErrorZ_free(self); } + CResult_LSPSRequestIdAPIErrorZ& operator=(CResult_LSPSRequestIdAPIErrorZ&& o) { CResult_LSPSRequestIdAPIErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_LSPSRequestIdAPIErrorZ)); return *this; } + LDKCResult_LSPSRequestIdAPIErrorZ* operator &() { return &self; } + LDKCResult_LSPSRequestIdAPIErrorZ* operator ->() { return &self; } + const LDKCResult_LSPSRequestIdAPIErrorZ* operator &() const { return &self; } + const LDKCResult_LSPSRequestIdAPIErrorZ* operator ->() const { return &self; } +}; class CResult_InFlightHtlcsDecodeErrorZ { private: LDKCResult_InFlightHtlcsDecodeErrorZ self; @@ -9758,20 +10638,20 @@ class CResult_NonePeerHandleErrorZ { const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; } const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; } }; -class CResult_TrustedCommitmentTransactionNoneZ { +class CResult_RawLSPSMessageDecodeErrorZ { private: - LDKCResult_TrustedCommitmentTransactionNoneZ self; + LDKCResult_RawLSPSMessageDecodeErrorZ self; public: - CResult_TrustedCommitmentTransactionNoneZ(const CResult_TrustedCommitmentTransactionNoneZ&) = delete; - CResult_TrustedCommitmentTransactionNoneZ(CResult_TrustedCommitmentTransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TrustedCommitmentTransactionNoneZ)); } - CResult_TrustedCommitmentTransactionNoneZ(LDKCResult_TrustedCommitmentTransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ)); } - operator LDKCResult_TrustedCommitmentTransactionNoneZ() && { LDKCResult_TrustedCommitmentTransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ)); return res; } - ~CResult_TrustedCommitmentTransactionNoneZ() { CResult_TrustedCommitmentTransactionNoneZ_free(self); } - CResult_TrustedCommitmentTransactionNoneZ& operator=(CResult_TrustedCommitmentTransactionNoneZ&& o) { CResult_TrustedCommitmentTransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TrustedCommitmentTransactionNoneZ)); return *this; } - LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() { return &self; } - LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() { return &self; } - const LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() const { return &self; } - const LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() const { return &self; } + CResult_RawLSPSMessageDecodeErrorZ(const CResult_RawLSPSMessageDecodeErrorZ&) = delete; + CResult_RawLSPSMessageDecodeErrorZ(CResult_RawLSPSMessageDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RawLSPSMessageDecodeErrorZ)); } + CResult_RawLSPSMessageDecodeErrorZ(LDKCResult_RawLSPSMessageDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RawLSPSMessageDecodeErrorZ)); } + operator LDKCResult_RawLSPSMessageDecodeErrorZ() && { LDKCResult_RawLSPSMessageDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RawLSPSMessageDecodeErrorZ)); return res; } + ~CResult_RawLSPSMessageDecodeErrorZ() { CResult_RawLSPSMessageDecodeErrorZ_free(self); } + CResult_RawLSPSMessageDecodeErrorZ& operator=(CResult_RawLSPSMessageDecodeErrorZ&& o) { CResult_RawLSPSMessageDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RawLSPSMessageDecodeErrorZ)); return *this; } + LDKCResult_RawLSPSMessageDecodeErrorZ* operator &() { return &self; } + LDKCResult_RawLSPSMessageDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_RawLSPSMessageDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_RawLSPSMessageDecodeErrorZ* operator ->() const { return &self; } }; class CResult_FinalOnionHopDataDecodeErrorZ { private: @@ -9788,20 +10668,20 @@ class CResult_FinalOnionHopDataDecodeErrorZ { const LDKCResult_FinalOnionHopDataDecodeErrorZ* operator &() const { return &self; } const LDKCResult_FinalOnionHopDataDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_COption_EventZDecodeErrorZ { +class CResult_TrustedCommitmentTransactionNoneZ { private: - LDKCResult_COption_EventZDecodeErrorZ self; + LDKCResult_TrustedCommitmentTransactionNoneZ self; public: - CResult_COption_EventZDecodeErrorZ(const CResult_COption_EventZDecodeErrorZ&) = delete; - CResult_COption_EventZDecodeErrorZ(CResult_COption_EventZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_EventZDecodeErrorZ)); } - CResult_COption_EventZDecodeErrorZ(LDKCResult_COption_EventZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_EventZDecodeErrorZ)); } - operator LDKCResult_COption_EventZDecodeErrorZ() && { LDKCResult_COption_EventZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_EventZDecodeErrorZ)); return res; } - ~CResult_COption_EventZDecodeErrorZ() { CResult_COption_EventZDecodeErrorZ_free(self); } - CResult_COption_EventZDecodeErrorZ& operator=(CResult_COption_EventZDecodeErrorZ&& o) { CResult_COption_EventZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_EventZDecodeErrorZ)); return *this; } - LDKCResult_COption_EventZDecodeErrorZ* operator &() { return &self; } - LDKCResult_COption_EventZDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_COption_EventZDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_COption_EventZDecodeErrorZ* operator ->() const { return &self; } + CResult_TrustedCommitmentTransactionNoneZ(const CResult_TrustedCommitmentTransactionNoneZ&) = delete; + CResult_TrustedCommitmentTransactionNoneZ(CResult_TrustedCommitmentTransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TrustedCommitmentTransactionNoneZ)); } + CResult_TrustedCommitmentTransactionNoneZ(LDKCResult_TrustedCommitmentTransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ)); } + operator LDKCResult_TrustedCommitmentTransactionNoneZ() && { LDKCResult_TrustedCommitmentTransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ)); return res; } + ~CResult_TrustedCommitmentTransactionNoneZ() { CResult_TrustedCommitmentTransactionNoneZ_free(self); } + CResult_TrustedCommitmentTransactionNoneZ& operator=(CResult_TrustedCommitmentTransactionNoneZ&& o) { CResult_TrustedCommitmentTransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TrustedCommitmentTransactionNoneZ)); return *this; } + LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() { return &self; } + LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() { return &self; } + const LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() const { return &self; } + const LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() const { return &self; } }; class CResult_DNSResolverMessageDecodeErrorZ { private: @@ -9833,6 +10713,21 @@ class C2Tuple_PublicKeyChannelIdZ { const LDKC2Tuple_PublicKeyChannelIdZ* operator &() const { return &self; } const LDKC2Tuple_PublicKeyChannelIdZ* operator ->() const { return &self; } }; +class CResult_COption_EventZDecodeErrorZ { +private: + LDKCResult_COption_EventZDecodeErrorZ self; +public: + CResult_COption_EventZDecodeErrorZ(const CResult_COption_EventZDecodeErrorZ&) = delete; + CResult_COption_EventZDecodeErrorZ(CResult_COption_EventZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_EventZDecodeErrorZ)); } + CResult_COption_EventZDecodeErrorZ(LDKCResult_COption_EventZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_EventZDecodeErrorZ)); } + operator LDKCResult_COption_EventZDecodeErrorZ() && { LDKCResult_COption_EventZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_EventZDecodeErrorZ)); return res; } + ~CResult_COption_EventZDecodeErrorZ() { CResult_COption_EventZDecodeErrorZ_free(self); } + CResult_COption_EventZDecodeErrorZ& operator=(CResult_COption_EventZDecodeErrorZ&& o) { CResult_COption_EventZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_EventZDecodeErrorZ)); return *this; } + LDKCResult_COption_EventZDecodeErrorZ* operator &() { return &self; } + LDKCResult_COption_EventZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_COption_EventZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_COption_EventZDecodeErrorZ* operator ->() const { return &self; } +}; class COption_SocketAddressZ { private: LDKCOption_SocketAddressZ self; @@ -10523,6 +11418,51 @@ class CResult_RouteParametersDecodeErrorZ { const LDKCResult_RouteParametersDecodeErrorZ* operator &() const { return &self; } const LDKCResult_RouteParametersDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_LSPSDateTimeNoneZ { +private: + LDKCResult_LSPSDateTimeNoneZ self; +public: + CResult_LSPSDateTimeNoneZ(const CResult_LSPSDateTimeNoneZ&) = delete; + CResult_LSPSDateTimeNoneZ(CResult_LSPSDateTimeNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_LSPSDateTimeNoneZ)); } + CResult_LSPSDateTimeNoneZ(LDKCResult_LSPSDateTimeNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_LSPSDateTimeNoneZ)); } + operator LDKCResult_LSPSDateTimeNoneZ() && { LDKCResult_LSPSDateTimeNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_LSPSDateTimeNoneZ)); return res; } + ~CResult_LSPSDateTimeNoneZ() { CResult_LSPSDateTimeNoneZ_free(self); } + CResult_LSPSDateTimeNoneZ& operator=(CResult_LSPSDateTimeNoneZ&& o) { CResult_LSPSDateTimeNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_LSPSDateTimeNoneZ)); return *this; } + LDKCResult_LSPSDateTimeNoneZ* operator &() { return &self; } + LDKCResult_LSPSDateTimeNoneZ* operator ->() { return &self; } + const LDKCResult_LSPSDateTimeNoneZ* operator &() const { return &self; } + const LDKCResult_LSPSDateTimeNoneZ* operator ->() const { return &self; } +}; +class CResult_u64NoneZ { +private: + LDKCResult_u64NoneZ self; +public: + CResult_u64NoneZ(const CResult_u64NoneZ&) = delete; + CResult_u64NoneZ(CResult_u64NoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_u64NoneZ)); } + CResult_u64NoneZ(LDKCResult_u64NoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_u64NoneZ)); } + operator LDKCResult_u64NoneZ() && { LDKCResult_u64NoneZ res = self; memset(&self, 0, sizeof(LDKCResult_u64NoneZ)); return res; } + ~CResult_u64NoneZ() { CResult_u64NoneZ_free(self); } + CResult_u64NoneZ& operator=(CResult_u64NoneZ&& o) { CResult_u64NoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_u64NoneZ)); return *this; } + LDKCResult_u64NoneZ* operator &() { return &self; } + LDKCResult_u64NoneZ* operator ->() { return &self; } + const LDKCResult_u64NoneZ* operator &() const { return &self; } + const LDKCResult_u64NoneZ* operator ->() const { return &self; } +}; +class CResult_NodeAliasDecodeErrorZ { +private: + LDKCResult_NodeAliasDecodeErrorZ self; +public: + CResult_NodeAliasDecodeErrorZ(const CResult_NodeAliasDecodeErrorZ&) = delete; + CResult_NodeAliasDecodeErrorZ(CResult_NodeAliasDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NodeAliasDecodeErrorZ)); } + CResult_NodeAliasDecodeErrorZ(LDKCResult_NodeAliasDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NodeAliasDecodeErrorZ)); } + operator LDKCResult_NodeAliasDecodeErrorZ() && { LDKCResult_NodeAliasDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NodeAliasDecodeErrorZ)); return res; } + ~CResult_NodeAliasDecodeErrorZ() { CResult_NodeAliasDecodeErrorZ_free(self); } + CResult_NodeAliasDecodeErrorZ& operator=(CResult_NodeAliasDecodeErrorZ&& o) { CResult_NodeAliasDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NodeAliasDecodeErrorZ)); return *this; } + LDKCResult_NodeAliasDecodeErrorZ* operator &() { return &self; } + LDKCResult_NodeAliasDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_NodeAliasDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_NodeAliasDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_PrivateRouteCreationErrorZ { private: LDKCResult_PrivateRouteCreationErrorZ self; @@ -10553,21 +11493,6 @@ class CResult_InvoiceErrorDecodeErrorZ { const LDKCResult_InvoiceErrorDecodeErrorZ* operator &() const { return &self; } const LDKCResult_InvoiceErrorDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_NodeAliasDecodeErrorZ { -private: - LDKCResult_NodeAliasDecodeErrorZ self; -public: - CResult_NodeAliasDecodeErrorZ(const CResult_NodeAliasDecodeErrorZ&) = delete; - CResult_NodeAliasDecodeErrorZ(CResult_NodeAliasDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NodeAliasDecodeErrorZ)); } - CResult_NodeAliasDecodeErrorZ(LDKCResult_NodeAliasDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NodeAliasDecodeErrorZ)); } - operator LDKCResult_NodeAliasDecodeErrorZ() && { LDKCResult_NodeAliasDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NodeAliasDecodeErrorZ)); return res; } - ~CResult_NodeAliasDecodeErrorZ() { CResult_NodeAliasDecodeErrorZ_free(self); } - CResult_NodeAliasDecodeErrorZ& operator=(CResult_NodeAliasDecodeErrorZ&& o) { CResult_NodeAliasDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NodeAliasDecodeErrorZ)); return *this; } - LDKCResult_NodeAliasDecodeErrorZ* operator &() { return &self; } - LDKCResult_NodeAliasDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_NodeAliasDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_NodeAliasDecodeErrorZ* operator ->() const { return &self; } -}; class C2Tuple_BestBlockOutputSweeperZ { private: LDKC2Tuple_BestBlockOutputSweeperZ self; @@ -10583,21 +11508,6 @@ class C2Tuple_BestBlockOutputSweeperZ { const LDKC2Tuple_BestBlockOutputSweeperZ* operator &() const { return &self; } const LDKC2Tuple_BestBlockOutputSweeperZ* operator ->() const { return &self; } }; -class C2Tuple_OutPointCVec_u64ZZ { -private: - LDKC2Tuple_OutPointCVec_u64ZZ self; -public: - C2Tuple_OutPointCVec_u64ZZ(const C2Tuple_OutPointCVec_u64ZZ&) = delete; - C2Tuple_OutPointCVec_u64ZZ(C2Tuple_OutPointCVec_u64ZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointCVec_u64ZZ)); } - C2Tuple_OutPointCVec_u64ZZ(LDKC2Tuple_OutPointCVec_u64ZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointCVec_u64ZZ)); } - operator LDKC2Tuple_OutPointCVec_u64ZZ() && { LDKC2Tuple_OutPointCVec_u64ZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointCVec_u64ZZ)); return res; } - ~C2Tuple_OutPointCVec_u64ZZ() { C2Tuple_OutPointCVec_u64ZZ_free(self); } - C2Tuple_OutPointCVec_u64ZZ& operator=(C2Tuple_OutPointCVec_u64ZZ&& o) { C2Tuple_OutPointCVec_u64ZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OutPointCVec_u64ZZ)); return *this; } - LDKC2Tuple_OutPointCVec_u64ZZ* operator &() { return &self; } - LDKC2Tuple_OutPointCVec_u64ZZ* operator ->() { return &self; } - const LDKC2Tuple_OutPointCVec_u64ZZ* operator &() const { return &self; } - const LDKC2Tuple_OutPointCVec_u64ZZ* operator ->() const { return &self; } -}; class CVec_UpdateFulfillHTLCZ { private: LDKCVec_UpdateFulfillHTLCZ self; @@ -10988,6 +11898,21 @@ class CVec_SpendableOutputDescriptorZ { const LDKCVec_SpendableOutputDescriptorZ* operator &() const { return &self; } const LDKCVec_SpendableOutputDescriptorZ* operator ->() const { return &self; } }; +class C2Tuple_OutPointCVec_u64ZZ { +private: + LDKC2Tuple_OutPointCVec_u64ZZ self; +public: + C2Tuple_OutPointCVec_u64ZZ(const C2Tuple_OutPointCVec_u64ZZ&) = delete; + C2Tuple_OutPointCVec_u64ZZ(C2Tuple_OutPointCVec_u64ZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointCVec_u64ZZ)); } + C2Tuple_OutPointCVec_u64ZZ(LDKC2Tuple_OutPointCVec_u64ZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointCVec_u64ZZ)); } + operator LDKC2Tuple_OutPointCVec_u64ZZ() && { LDKC2Tuple_OutPointCVec_u64ZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointCVec_u64ZZ)); return res; } + ~C2Tuple_OutPointCVec_u64ZZ() { C2Tuple_OutPointCVec_u64ZZ_free(self); } + C2Tuple_OutPointCVec_u64ZZ& operator=(C2Tuple_OutPointCVec_u64ZZ&& o) { C2Tuple_OutPointCVec_u64ZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OutPointCVec_u64ZZ)); return *this; } + LDKC2Tuple_OutPointCVec_u64ZZ* operator &() { return &self; } + LDKC2Tuple_OutPointCVec_u64ZZ* operator ->() { return &self; } + const LDKC2Tuple_OutPointCVec_u64ZZ* operator &() const { return &self; } + const LDKC2Tuple_OutPointCVec_u64ZZ* operator ->() const { return &self; } +}; class CResult_ResponderDecodeErrorZ { private: LDKCResult_ResponderDecodeErrorZ self; @@ -11168,6 +12093,21 @@ class CResult_AsyncPaymentsMessageDecodeErrorZ { const LDKCResult_AsyncPaymentsMessageDecodeErrorZ* operator &() const { return &self; } const LDKCResult_AsyncPaymentsMessageDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_LSPS2OpeningFeeParamsZ { +private: + LDKCVec_LSPS2OpeningFeeParamsZ self; +public: + CVec_LSPS2OpeningFeeParamsZ(const CVec_LSPS2OpeningFeeParamsZ&) = delete; + CVec_LSPS2OpeningFeeParamsZ(CVec_LSPS2OpeningFeeParamsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_LSPS2OpeningFeeParamsZ)); } + CVec_LSPS2OpeningFeeParamsZ(LDKCVec_LSPS2OpeningFeeParamsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_LSPS2OpeningFeeParamsZ)); } + operator LDKCVec_LSPS2OpeningFeeParamsZ() && { LDKCVec_LSPS2OpeningFeeParamsZ res = self; memset(&self, 0, sizeof(LDKCVec_LSPS2OpeningFeeParamsZ)); return res; } + ~CVec_LSPS2OpeningFeeParamsZ() { CVec_LSPS2OpeningFeeParamsZ_free(self); } + CVec_LSPS2OpeningFeeParamsZ& operator=(CVec_LSPS2OpeningFeeParamsZ&& o) { CVec_LSPS2OpeningFeeParamsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_LSPS2OpeningFeeParamsZ)); return *this; } + LDKCVec_LSPS2OpeningFeeParamsZ* operator &() { return &self; } + LDKCVec_LSPS2OpeningFeeParamsZ* operator ->() { return &self; } + const LDKCVec_LSPS2OpeningFeeParamsZ* operator &() const { return &self; } + const LDKCVec_LSPS2OpeningFeeParamsZ* operator ->() const { return &self; } +}; class CResult_SpliceAckDecodeErrorZ { private: LDKCResult_SpliceAckDecodeErrorZ self; @@ -11948,20 +12888,20 @@ class C2Tuple_Z { const LDKC2Tuple_Z* operator &() const { return &self; } const LDKC2Tuple_Z* operator ->() const { return &self; } }; -class CResult_TxCreationKeysDecodeErrorZ { +class COption_AddressZ { private: - LDKCResult_TxCreationKeysDecodeErrorZ self; + LDKCOption_AddressZ self; public: - CResult_TxCreationKeysDecodeErrorZ(const CResult_TxCreationKeysDecodeErrorZ&) = delete; - CResult_TxCreationKeysDecodeErrorZ(CResult_TxCreationKeysDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); } - CResult_TxCreationKeysDecodeErrorZ(LDKCResult_TxCreationKeysDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); } - operator LDKCResult_TxCreationKeysDecodeErrorZ() && { LDKCResult_TxCreationKeysDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); return res; } - ~CResult_TxCreationKeysDecodeErrorZ() { CResult_TxCreationKeysDecodeErrorZ_free(self); } - CResult_TxCreationKeysDecodeErrorZ& operator=(CResult_TxCreationKeysDecodeErrorZ&& o) { CResult_TxCreationKeysDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); return *this; } - LDKCResult_TxCreationKeysDecodeErrorZ* operator &() { return &self; } - LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_TxCreationKeysDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() const { return &self; } + COption_AddressZ(const COption_AddressZ&) = delete; + COption_AddressZ(COption_AddressZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_AddressZ)); } + COption_AddressZ(LDKCOption_AddressZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_AddressZ)); } + operator LDKCOption_AddressZ() && { LDKCOption_AddressZ res = self; memset(&self, 0, sizeof(LDKCOption_AddressZ)); return res; } + ~COption_AddressZ() { COption_AddressZ_free(self); } + COption_AddressZ& operator=(COption_AddressZ&& o) { COption_AddressZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_AddressZ)); return *this; } + LDKCOption_AddressZ* operator &() { return &self; } + LDKCOption_AddressZ* operator ->() { return &self; } + const LDKCOption_AddressZ* operator &() const { return &self; } + const LDKCOption_AddressZ* operator ->() const { return &self; } }; class CResult_InboundHTLCDetailsDecodeErrorZ { private: @@ -11978,20 +12918,20 @@ class CResult_InboundHTLCDetailsDecodeErrorZ { const LDKCResult_InboundHTLCDetailsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_InboundHTLCDetailsDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_ShutdownScriptDecodeErrorZ { +class CResult_TxCreationKeysDecodeErrorZ { private: - LDKCResult_ShutdownScriptDecodeErrorZ self; + LDKCResult_TxCreationKeysDecodeErrorZ self; public: - CResult_ShutdownScriptDecodeErrorZ(const CResult_ShutdownScriptDecodeErrorZ&) = delete; - CResult_ShutdownScriptDecodeErrorZ(CResult_ShutdownScriptDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); } - CResult_ShutdownScriptDecodeErrorZ(LDKCResult_ShutdownScriptDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); } - operator LDKCResult_ShutdownScriptDecodeErrorZ() && { LDKCResult_ShutdownScriptDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); return res; } - ~CResult_ShutdownScriptDecodeErrorZ() { CResult_ShutdownScriptDecodeErrorZ_free(self); } - CResult_ShutdownScriptDecodeErrorZ& operator=(CResult_ShutdownScriptDecodeErrorZ&& o) { CResult_ShutdownScriptDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); return *this; } - LDKCResult_ShutdownScriptDecodeErrorZ* operator &() { return &self; } - LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ShutdownScriptDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() const { return &self; } + CResult_TxCreationKeysDecodeErrorZ(const CResult_TxCreationKeysDecodeErrorZ&) = delete; + CResult_TxCreationKeysDecodeErrorZ(CResult_TxCreationKeysDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); } + CResult_TxCreationKeysDecodeErrorZ(LDKCResult_TxCreationKeysDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); } + operator LDKCResult_TxCreationKeysDecodeErrorZ() && { LDKCResult_TxCreationKeysDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); return res; } + ~CResult_TxCreationKeysDecodeErrorZ() { CResult_TxCreationKeysDecodeErrorZ_free(self); } + CResult_TxCreationKeysDecodeErrorZ& operator=(CResult_TxCreationKeysDecodeErrorZ&& o) { CResult_TxCreationKeysDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); return *this; } + LDKCResult_TxCreationKeysDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxCreationKeysDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() const { return &self; } }; class C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { private: @@ -12008,20 +12948,20 @@ class C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { const LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* operator &() const { return &self; } const LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* operator ->() const { return &self; } }; -class CResult_SiPrefixBolt11ParseErrorZ { +class CResult_ShutdownScriptDecodeErrorZ { private: - LDKCResult_SiPrefixBolt11ParseErrorZ self; + LDKCResult_ShutdownScriptDecodeErrorZ self; public: - CResult_SiPrefixBolt11ParseErrorZ(const CResult_SiPrefixBolt11ParseErrorZ&) = delete; - CResult_SiPrefixBolt11ParseErrorZ(CResult_SiPrefixBolt11ParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SiPrefixBolt11ParseErrorZ)); } - CResult_SiPrefixBolt11ParseErrorZ(LDKCResult_SiPrefixBolt11ParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ)); } - operator LDKCResult_SiPrefixBolt11ParseErrorZ() && { LDKCResult_SiPrefixBolt11ParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ)); return res; } - ~CResult_SiPrefixBolt11ParseErrorZ() { CResult_SiPrefixBolt11ParseErrorZ_free(self); } - CResult_SiPrefixBolt11ParseErrorZ& operator=(CResult_SiPrefixBolt11ParseErrorZ&& o) { CResult_SiPrefixBolt11ParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SiPrefixBolt11ParseErrorZ)); return *this; } - LDKCResult_SiPrefixBolt11ParseErrorZ* operator &() { return &self; } - LDKCResult_SiPrefixBolt11ParseErrorZ* operator ->() { return &self; } - const LDKCResult_SiPrefixBolt11ParseErrorZ* operator &() const { return &self; } - const LDKCResult_SiPrefixBolt11ParseErrorZ* operator ->() const { return &self; } + CResult_ShutdownScriptDecodeErrorZ(const CResult_ShutdownScriptDecodeErrorZ&) = delete; + CResult_ShutdownScriptDecodeErrorZ(CResult_ShutdownScriptDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); } + CResult_ShutdownScriptDecodeErrorZ(LDKCResult_ShutdownScriptDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); } + operator LDKCResult_ShutdownScriptDecodeErrorZ() && { LDKCResult_ShutdownScriptDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); return res; } + ~CResult_ShutdownScriptDecodeErrorZ() { CResult_ShutdownScriptDecodeErrorZ_free(self); } + CResult_ShutdownScriptDecodeErrorZ& operator=(CResult_ShutdownScriptDecodeErrorZ&& o) { CResult_ShutdownScriptDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); return *this; } + LDKCResult_ShutdownScriptDecodeErrorZ* operator &() { return &self; } + LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ShutdownScriptDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() const { return &self; } }; class CVec_PathZ { private: @@ -12053,6 +12993,21 @@ class CResult_NetworkGraphDecodeErrorZ { const LDKCResult_NetworkGraphDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NetworkGraphDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_SiPrefixBolt11ParseErrorZ { +private: + LDKCResult_SiPrefixBolt11ParseErrorZ self; +public: + CResult_SiPrefixBolt11ParseErrorZ(const CResult_SiPrefixBolt11ParseErrorZ&) = delete; + CResult_SiPrefixBolt11ParseErrorZ(CResult_SiPrefixBolt11ParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SiPrefixBolt11ParseErrorZ)); } + CResult_SiPrefixBolt11ParseErrorZ(LDKCResult_SiPrefixBolt11ParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ)); } + operator LDKCResult_SiPrefixBolt11ParseErrorZ() && { LDKCResult_SiPrefixBolt11ParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ)); return res; } + ~CResult_SiPrefixBolt11ParseErrorZ() { CResult_SiPrefixBolt11ParseErrorZ_free(self); } + CResult_SiPrefixBolt11ParseErrorZ& operator=(CResult_SiPrefixBolt11ParseErrorZ&& o) { CResult_SiPrefixBolt11ParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SiPrefixBolt11ParseErrorZ)); return *this; } + LDKCResult_SiPrefixBolt11ParseErrorZ* operator &() { return &self; } + LDKCResult_SiPrefixBolt11ParseErrorZ* operator ->() { return &self; } + const LDKCResult_SiPrefixBolt11ParseErrorZ* operator &() const { return &self; } + const LDKCResult_SiPrefixBolt11ParseErrorZ* operator ->() const { return &self; } +}; class CResult_NodeInfoDecodeErrorZ { private: LDKCResult_NodeInfoDecodeErrorZ self; @@ -12353,6 +13308,21 @@ class CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { const LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_LSPS2RawOpeningFeeParamsZ { +private: + LDKCVec_LSPS2RawOpeningFeeParamsZ self; +public: + CVec_LSPS2RawOpeningFeeParamsZ(const CVec_LSPS2RawOpeningFeeParamsZ&) = delete; + CVec_LSPS2RawOpeningFeeParamsZ(CVec_LSPS2RawOpeningFeeParamsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_LSPS2RawOpeningFeeParamsZ)); } + CVec_LSPS2RawOpeningFeeParamsZ(LDKCVec_LSPS2RawOpeningFeeParamsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_LSPS2RawOpeningFeeParamsZ)); } + operator LDKCVec_LSPS2RawOpeningFeeParamsZ() && { LDKCVec_LSPS2RawOpeningFeeParamsZ res = self; memset(&self, 0, sizeof(LDKCVec_LSPS2RawOpeningFeeParamsZ)); return res; } + ~CVec_LSPS2RawOpeningFeeParamsZ() { CVec_LSPS2RawOpeningFeeParamsZ_free(self); } + CVec_LSPS2RawOpeningFeeParamsZ& operator=(CVec_LSPS2RawOpeningFeeParamsZ&& o) { CVec_LSPS2RawOpeningFeeParamsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_LSPS2RawOpeningFeeParamsZ)); return *this; } + LDKCVec_LSPS2RawOpeningFeeParamsZ* operator &() { return &self; } + LDKCVec_LSPS2RawOpeningFeeParamsZ* operator ->() { return &self; } + const LDKCVec_LSPS2RawOpeningFeeParamsZ* operator &() const { return &self; } + const LDKCVec_LSPS2RawOpeningFeeParamsZ* operator ->() const { return &self; } +}; class CResult_InitDecodeErrorZ { private: LDKCResult_InitDecodeErrorZ self; @@ -12398,21 +13368,6 @@ class CResult_ClaimedHTLCDecodeErrorZ { const LDKCResult_ClaimedHTLCDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ClaimedHTLCDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_OutPointDecodeErrorZ { -private: - LDKCResult_OutPointDecodeErrorZ self; -public: - CResult_OutPointDecodeErrorZ(const CResult_OutPointDecodeErrorZ&) = delete; - CResult_OutPointDecodeErrorZ(CResult_OutPointDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OutPointDecodeErrorZ)); } - CResult_OutPointDecodeErrorZ(LDKCResult_OutPointDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OutPointDecodeErrorZ)); } - operator LDKCResult_OutPointDecodeErrorZ() && { LDKCResult_OutPointDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OutPointDecodeErrorZ)); return res; } - ~CResult_OutPointDecodeErrorZ() { CResult_OutPointDecodeErrorZ_free(self); } - CResult_OutPointDecodeErrorZ& operator=(CResult_OutPointDecodeErrorZ&& o) { CResult_OutPointDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OutPointDecodeErrorZ)); return *this; } - LDKCResult_OutPointDecodeErrorZ* operator &() { return &self; } - LDKCResult_OutPointDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_OutPointDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_OutPointDecodeErrorZ* operator ->() const { return &self; } -}; class CVec_ChannelDetailsZ { private: LDKCVec_ChannelDetailsZ self; @@ -12428,20 +13383,20 @@ class CVec_ChannelDetailsZ { const LDKCVec_ChannelDetailsZ* operator &() const { return &self; } const LDKCVec_ChannelDetailsZ* operator ->() const { return &self; } }; -class CResult_DNSResolverContextDecodeErrorZ { +class CResult_OutPointDecodeErrorZ { private: - LDKCResult_DNSResolverContextDecodeErrorZ self; + LDKCResult_OutPointDecodeErrorZ self; public: - CResult_DNSResolverContextDecodeErrorZ(const CResult_DNSResolverContextDecodeErrorZ&) = delete; - CResult_DNSResolverContextDecodeErrorZ(CResult_DNSResolverContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_DNSResolverContextDecodeErrorZ)); } - CResult_DNSResolverContextDecodeErrorZ(LDKCResult_DNSResolverContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_DNSResolverContextDecodeErrorZ)); } - operator LDKCResult_DNSResolverContextDecodeErrorZ() && { LDKCResult_DNSResolverContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_DNSResolverContextDecodeErrorZ)); return res; } - ~CResult_DNSResolverContextDecodeErrorZ() { CResult_DNSResolverContextDecodeErrorZ_free(self); } - CResult_DNSResolverContextDecodeErrorZ& operator=(CResult_DNSResolverContextDecodeErrorZ&& o) { CResult_DNSResolverContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_DNSResolverContextDecodeErrorZ)); return *this; } - LDKCResult_DNSResolverContextDecodeErrorZ* operator &() { return &self; } - LDKCResult_DNSResolverContextDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_DNSResolverContextDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_DNSResolverContextDecodeErrorZ* operator ->() const { return &self; } + CResult_OutPointDecodeErrorZ(const CResult_OutPointDecodeErrorZ&) = delete; + CResult_OutPointDecodeErrorZ(CResult_OutPointDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OutPointDecodeErrorZ)); } + CResult_OutPointDecodeErrorZ(LDKCResult_OutPointDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OutPointDecodeErrorZ)); } + operator LDKCResult_OutPointDecodeErrorZ() && { LDKCResult_OutPointDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OutPointDecodeErrorZ)); return res; } + ~CResult_OutPointDecodeErrorZ() { CResult_OutPointDecodeErrorZ_free(self); } + CResult_OutPointDecodeErrorZ& operator=(CResult_OutPointDecodeErrorZ&& o) { CResult_OutPointDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OutPointDecodeErrorZ)); return *this; } + LDKCResult_OutPointDecodeErrorZ* operator &() { return &self; } + LDKCResult_OutPointDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OutPointDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OutPointDecodeErrorZ* operator ->() const { return &self; } }; class CVec_MessageSendEventZ { private: @@ -12473,6 +13428,21 @@ class CResult_Bolt11InvoiceFeaturesDecodeErrorZ { const LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_DNSResolverContextDecodeErrorZ { +private: + LDKCResult_DNSResolverContextDecodeErrorZ self; +public: + CResult_DNSResolverContextDecodeErrorZ(const CResult_DNSResolverContextDecodeErrorZ&) = delete; + CResult_DNSResolverContextDecodeErrorZ(CResult_DNSResolverContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_DNSResolverContextDecodeErrorZ)); } + CResult_DNSResolverContextDecodeErrorZ(LDKCResult_DNSResolverContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_DNSResolverContextDecodeErrorZ)); } + operator LDKCResult_DNSResolverContextDecodeErrorZ() && { LDKCResult_DNSResolverContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_DNSResolverContextDecodeErrorZ)); return res; } + ~CResult_DNSResolverContextDecodeErrorZ() { CResult_DNSResolverContextDecodeErrorZ_free(self); } + CResult_DNSResolverContextDecodeErrorZ& operator=(CResult_DNSResolverContextDecodeErrorZ&& o) { CResult_DNSResolverContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_DNSResolverContextDecodeErrorZ)); return *this; } + LDKCResult_DNSResolverContextDecodeErrorZ* operator &() { return &self; } + LDKCResult_DNSResolverContextDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_DNSResolverContextDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_DNSResolverContextDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { private: LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ self; @@ -13103,6 +14073,21 @@ class CVec_C2Tuple_PublicKeyTypeZZ { const LDKCVec_C2Tuple_PublicKeyTypeZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_PublicKeyTypeZZ* operator ->() const { return &self; } }; +class CVec_u16Z { +private: + LDKCVec_u16Z self; +public: + CVec_u16Z(const CVec_u16Z&) = delete; + CVec_u16Z(CVec_u16Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u16Z)); } + CVec_u16Z(LDKCVec_u16Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u16Z)); } + operator LDKCVec_u16Z() && { LDKCVec_u16Z res = self; memset(&self, 0, sizeof(LDKCVec_u16Z)); return res; } + ~CVec_u16Z() { CVec_u16Z_free(self); } + CVec_u16Z& operator=(CVec_u16Z&& o) { CVec_u16Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_u16Z)); return *this; } + LDKCVec_u16Z* operator &() { return &self; } + LDKCVec_u16Z* operator ->() { return &self; } + const LDKCVec_u16Z* operator &() const { return &self; } + const LDKCVec_u16Z* operator ->() const { return &self; } +}; class CResult_OutboundHTLCDetailsDecodeErrorZ { private: LDKCResult_OutboundHTLCDetailsDecodeErrorZ self; @@ -13118,21 +14103,6 @@ class CResult_OutboundHTLCDetailsDecodeErrorZ { const LDKCResult_OutboundHTLCDetailsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_OutboundHTLCDetailsDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_OnionMessagePathNoneZ { -private: - LDKCResult_OnionMessagePathNoneZ self; -public: - CResult_OnionMessagePathNoneZ(const CResult_OnionMessagePathNoneZ&) = delete; - CResult_OnionMessagePathNoneZ(CResult_OnionMessagePathNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OnionMessagePathNoneZ)); } - CResult_OnionMessagePathNoneZ(LDKCResult_OnionMessagePathNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OnionMessagePathNoneZ)); } - operator LDKCResult_OnionMessagePathNoneZ() && { LDKCResult_OnionMessagePathNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_OnionMessagePathNoneZ)); return res; } - ~CResult_OnionMessagePathNoneZ() { CResult_OnionMessagePathNoneZ_free(self); } - CResult_OnionMessagePathNoneZ& operator=(CResult_OnionMessagePathNoneZ&& o) { CResult_OnionMessagePathNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OnionMessagePathNoneZ)); return *this; } - LDKCResult_OnionMessagePathNoneZ* operator &() { return &self; } - LDKCResult_OnionMessagePathNoneZ* operator ->() { return &self; } - const LDKCResult_OnionMessagePathNoneZ* operator &() const { return &self; } - const LDKCResult_OnionMessagePathNoneZ* operator ->() const { return &self; } -}; class CResult_RefundBolt12ParseErrorZ { private: LDKCResult_RefundBolt12ParseErrorZ self; @@ -13193,20 +14163,20 @@ class CResult_OffersMessageDecodeErrorZ { const LDKCResult_OffersMessageDecodeErrorZ* operator &() const { return &self; } const LDKCResult_OffersMessageDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_PhantomRouteHintsZ { +class CResult_OnionMessagePathNoneZ { private: - LDKCVec_PhantomRouteHintsZ self; + LDKCResult_OnionMessagePathNoneZ self; public: - CVec_PhantomRouteHintsZ(const CVec_PhantomRouteHintsZ&) = delete; - CVec_PhantomRouteHintsZ(CVec_PhantomRouteHintsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); } - CVec_PhantomRouteHintsZ(LDKCVec_PhantomRouteHintsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); } - operator LDKCVec_PhantomRouteHintsZ() && { LDKCVec_PhantomRouteHintsZ res = self; memset(&self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); return res; } - ~CVec_PhantomRouteHintsZ() { CVec_PhantomRouteHintsZ_free(self); } - CVec_PhantomRouteHintsZ& operator=(CVec_PhantomRouteHintsZ&& o) { CVec_PhantomRouteHintsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); return *this; } - LDKCVec_PhantomRouteHintsZ* operator &() { return &self; } - LDKCVec_PhantomRouteHintsZ* operator ->() { return &self; } - const LDKCVec_PhantomRouteHintsZ* operator &() const { return &self; } - const LDKCVec_PhantomRouteHintsZ* operator ->() const { return &self; } + CResult_OnionMessagePathNoneZ(const CResult_OnionMessagePathNoneZ&) = delete; + CResult_OnionMessagePathNoneZ(CResult_OnionMessagePathNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OnionMessagePathNoneZ)); } + CResult_OnionMessagePathNoneZ(LDKCResult_OnionMessagePathNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OnionMessagePathNoneZ)); } + operator LDKCResult_OnionMessagePathNoneZ() && { LDKCResult_OnionMessagePathNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_OnionMessagePathNoneZ)); return res; } + ~CResult_OnionMessagePathNoneZ() { CResult_OnionMessagePathNoneZ_free(self); } + CResult_OnionMessagePathNoneZ& operator=(CResult_OnionMessagePathNoneZ&& o) { CResult_OnionMessagePathNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OnionMessagePathNoneZ)); return *this; } + LDKCResult_OnionMessagePathNoneZ* operator &() { return &self; } + LDKCResult_OnionMessagePathNoneZ* operator ->() { return &self; } + const LDKCResult_OnionMessagePathNoneZ* operator &() const { return &self; } + const LDKCResult_OnionMessagePathNoneZ* operator ->() const { return &self; } }; class CResult_NoneAPIErrorZ { private: @@ -13568,6 +14538,21 @@ class CVec_PrivateRouteZ { const LDKCVec_PrivateRouteZ* operator &() const { return &self; } const LDKCVec_PrivateRouteZ* operator ->() const { return &self; } }; +class CVec_PhantomRouteHintsZ { +private: + LDKCVec_PhantomRouteHintsZ self; +public: + CVec_PhantomRouteHintsZ(const CVec_PhantomRouteHintsZ&) = delete; + CVec_PhantomRouteHintsZ(CVec_PhantomRouteHintsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); } + CVec_PhantomRouteHintsZ(LDKCVec_PhantomRouteHintsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); } + operator LDKCVec_PhantomRouteHintsZ() && { LDKCVec_PhantomRouteHintsZ res = self; memset(&self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); return res; } + ~CVec_PhantomRouteHintsZ() { CVec_PhantomRouteHintsZ_free(self); } + CVec_PhantomRouteHintsZ& operator=(CVec_PhantomRouteHintsZ&& o) { CVec_PhantomRouteHintsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); return *this; } + LDKCVec_PhantomRouteHintsZ* operator &() { return &self; } + LDKCVec_PhantomRouteHintsZ* operator ->() { return &self; } + const LDKCVec_PhantomRouteHintsZ* operator &() const { return &self; } + const LDKCVec_PhantomRouteHintsZ* operator ->() const { return &self; } +}; class CVec_C2Tuple_OutPointCVec_u64ZZZ { private: LDKCVec_C2Tuple_OutPointCVec_u64ZZZ self; @@ -13778,6 +14763,21 @@ class CResult_OffersContextDecodeErrorZ { const LDKCResult_OffersContextDecodeErrorZ* operator &() const { return &self; } const LDKCResult_OffersContextDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_AddressZ { +private: + LDKCVec_AddressZ self; +public: + CVec_AddressZ(const CVec_AddressZ&) = delete; + CVec_AddressZ(CVec_AddressZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_AddressZ)); } + CVec_AddressZ(LDKCVec_AddressZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_AddressZ)); } + operator LDKCVec_AddressZ() && { LDKCVec_AddressZ res = self; memset(&self, 0, sizeof(LDKCVec_AddressZ)); return res; } + ~CVec_AddressZ() { CVec_AddressZ_free(self); } + CVec_AddressZ& operator=(CVec_AddressZ&& o) { CVec_AddressZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_AddressZ)); return *this; } + LDKCVec_AddressZ* operator &() { return &self; } + LDKCVec_AddressZ* operator ->() { return &self; } + const LDKCVec_AddressZ* operator &() const { return &self; } + const LDKCVec_AddressZ* operator ->() const { return &self; } +}; class CResult_NoneNoneZ { private: LDKCResult_NoneNoneZ self; @@ -13808,21 +14808,6 @@ class CResult_boolPeerHandleErrorZ { const LDKCResult_boolPeerHandleErrorZ* operator &() const { return &self; } const LDKCResult_boolPeerHandleErrorZ* operator ->() const { return &self; } }; -class CResult_ChannelUpdateDecodeErrorZ { -private: - LDKCResult_ChannelUpdateDecodeErrorZ self; -public: - CResult_ChannelUpdateDecodeErrorZ(const CResult_ChannelUpdateDecodeErrorZ&) = delete; - CResult_ChannelUpdateDecodeErrorZ(CResult_ChannelUpdateDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); } - CResult_ChannelUpdateDecodeErrorZ(LDKCResult_ChannelUpdateDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); } - operator LDKCResult_ChannelUpdateDecodeErrorZ() && { LDKCResult_ChannelUpdateDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); return res; } - ~CResult_ChannelUpdateDecodeErrorZ() { CResult_ChannelUpdateDecodeErrorZ_free(self); } - CResult_ChannelUpdateDecodeErrorZ& operator=(CResult_ChannelUpdateDecodeErrorZ&& o) { CResult_ChannelUpdateDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); return *this; } - LDKCResult_ChannelUpdateDecodeErrorZ* operator &() { return &self; } - LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ChannelUpdateDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() const { return &self; } -}; class COption_TxOutZ { private: LDKCOption_TxOutZ self; @@ -13838,6 +14823,21 @@ class COption_TxOutZ { const LDKCOption_TxOutZ* operator &() const { return &self; } const LDKCOption_TxOutZ* operator ->() const { return &self; } }; +class CResult_ChannelUpdateDecodeErrorZ { +private: + LDKCResult_ChannelUpdateDecodeErrorZ self; +public: + CResult_ChannelUpdateDecodeErrorZ(const CResult_ChannelUpdateDecodeErrorZ&) = delete; + CResult_ChannelUpdateDecodeErrorZ(CResult_ChannelUpdateDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); } + CResult_ChannelUpdateDecodeErrorZ(LDKCResult_ChannelUpdateDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); } + operator LDKCResult_ChannelUpdateDecodeErrorZ() && { LDKCResult_ChannelUpdateDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); return res; } + ~CResult_ChannelUpdateDecodeErrorZ() { CResult_ChannelUpdateDecodeErrorZ_free(self); } + CResult_ChannelUpdateDecodeErrorZ& operator=(CResult_ChannelUpdateDecodeErrorZ&& o) { CResult_ChannelUpdateDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); return *this; } + LDKCResult_ChannelUpdateDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelUpdateDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() const { return &self; } +}; class COption_ClosureReasonZ { private: LDKCOption_ClosureReasonZ self; @@ -13853,21 +14853,6 @@ class COption_ClosureReasonZ { const LDKCOption_ClosureReasonZ* operator &() const { return &self; } const LDKCOption_ClosureReasonZ* operator ->() const { return &self; } }; -class CResult_TransactionU16LenLimitedDecodeErrorZ { -private: - LDKCResult_TransactionU16LenLimitedDecodeErrorZ self; -public: - CResult_TransactionU16LenLimitedDecodeErrorZ(const CResult_TransactionU16LenLimitedDecodeErrorZ&) = delete; - CResult_TransactionU16LenLimitedDecodeErrorZ(CResult_TransactionU16LenLimitedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TransactionU16LenLimitedDecodeErrorZ)); } - CResult_TransactionU16LenLimitedDecodeErrorZ(LDKCResult_TransactionU16LenLimitedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ)); } - operator LDKCResult_TransactionU16LenLimitedDecodeErrorZ() && { LDKCResult_TransactionU16LenLimitedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ)); return res; } - ~CResult_TransactionU16LenLimitedDecodeErrorZ() { CResult_TransactionU16LenLimitedDecodeErrorZ_free(self); } - CResult_TransactionU16LenLimitedDecodeErrorZ& operator=(CResult_TransactionU16LenLimitedDecodeErrorZ&& o) { CResult_TransactionU16LenLimitedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TransactionU16LenLimitedDecodeErrorZ)); return *this; } - LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator &() { return &self; } - LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator ->() const { return &self; } -}; class CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { private: LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ self; @@ -13898,6 +14883,21 @@ class CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { const LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* operator &() const { return &self; } const LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* operator ->() const { return &self; } }; +class CResult_TransactionU16LenLimitedDecodeErrorZ { +private: + LDKCResult_TransactionU16LenLimitedDecodeErrorZ self; +public: + CResult_TransactionU16LenLimitedDecodeErrorZ(const CResult_TransactionU16LenLimitedDecodeErrorZ&) = delete; + CResult_TransactionU16LenLimitedDecodeErrorZ(CResult_TransactionU16LenLimitedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TransactionU16LenLimitedDecodeErrorZ)); } + CResult_TransactionU16LenLimitedDecodeErrorZ(LDKCResult_TransactionU16LenLimitedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ)); } + operator LDKCResult_TransactionU16LenLimitedDecodeErrorZ() && { LDKCResult_TransactionU16LenLimitedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ)); return res; } + ~CResult_TransactionU16LenLimitedDecodeErrorZ() { CResult_TransactionU16LenLimitedDecodeErrorZ_free(self); } + CResult_TransactionU16LenLimitedDecodeErrorZ& operator=(CResult_TransactionU16LenLimitedDecodeErrorZ&& o) { CResult_TransactionU16LenLimitedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TransactionU16LenLimitedDecodeErrorZ)); return *this; } + LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator &() { return &self; } + LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_FundingInfoDecodeErrorZ { private: LDKCResult_FundingInfoDecodeErrorZ self; @@ -14836,6 +15836,9 @@ inline LDKPublicKey NodeIdLookUp::next_node_id(uint64_t short_channel_id) { LDKPublicKey ret = (self.next_node_id)(self.this_arg, short_channel_id); return ret; } +inline void ProcessMessagesCallback::call() { + (self.call)(self.this_arg); +} inline LDK::ChannelMonitorUpdateStatus Persist::persist_new_channel(struct LDKOutPoint channel_funding_outpoint, const struct LDKChannelMonitor *NONNULL_PTR monitor) { LDK::ChannelMonitorUpdateStatus ret = (self.persist_new_channel)(self.this_arg, channel_funding_outpoint, monitor); return ret; diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index 07c6ef1a..106a029c 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -2129,29 +2129,29 @@ impl Clone for CVec_BlindedPaymentPathZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::Strs of arbitrary size. +/// A dynamically-allocated array of crate::c_types::Addresss of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_StrZ { +pub struct CVec_AddressZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::Str, + pub data: *mut crate::c_types::Address, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_StrZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_AddressZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Str] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Address] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_StrZ { - fn from(v: Vec) -> Self { +impl From> for CVec_AddressZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -2159,21 +2159,13 @@ impl From> for CVec_StrZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_StrZ_free(_res: CVec_StrZ) { } -impl Drop for CVec_StrZ { +pub extern "C" fn CVec_AddressZ_free(_res: CVec_AddressZ) { } +impl Drop for CVec_AddressZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_StrZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} #[repr(C)] /// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. /// This corresponds to std::vector in C++ @@ -6110,6 +6102,52 @@ impl Clone for CVec_PublicKeyZ { } } #[repr(C)] +/// A dynamically-allocated array of u16s of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_u16Z { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut u16, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_u16Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u16] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_u16Z { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_u16Z_free(_res: CVec_u16Z) { } +impl Drop for CVec_u16Z { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_u16Z { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] /// The contents of CResult_FixedPenaltyScorerDecodeErrorZ pub union CResult_FixedPenaltyScorerDecodeErrorZPtr { /// A pointer to the contents in the success state. @@ -7049,6 +7087,217 @@ impl Clone for CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { } } #[repr(C)] +/// An enum which can either contain a crate::c_types::Address or not +pub enum COption_AddressZ { + /// When we're in this state, this COption_AddressZ contains a crate::c_types::Address + Some(crate::c_types::Address), + /// When we're in this state, this COption_AddressZ contains nothing + None +} +impl COption_AddressZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::Address { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_AddressZ containing a crate::c_types::Address +pub extern "C" fn COption_AddressZ_some(o: crate::c_types::Address) -> COption_AddressZ { + COption_AddressZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_AddressZ containing nothing +pub extern "C" fn COption_AddressZ_none() -> COption_AddressZ { + COption_AddressZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::Address, if we are in the Some state +pub extern "C" fn COption_AddressZ_free(_res: COption_AddressZ) { } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::Str or not +pub enum COption_StrZ { + /// When we're in this state, this COption_StrZ contains a crate::c_types::Str + Some(crate::c_types::Str), + /// When we're in this state, this COption_StrZ contains nothing + None +} +impl COption_StrZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::Str { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_StrZ containing a crate::c_types::Str +pub extern "C" fn COption_StrZ_some(o: crate::c_types::Str) -> COption_StrZ { + COption_StrZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_StrZ containing nothing +pub extern "C" fn COption_StrZ_none() -> COption_StrZ { + COption_StrZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::Str, if we are in the Some state +pub extern "C" fn COption_StrZ_free(_res: COption_StrZ) { } +#[no_mangle] +/// Creates a new COption_StrZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_StrZ_clone(orig: &COption_StrZ) -> COption_StrZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_LSPSRequestIdAPIErrorZ +pub union CResult_LSPSRequestIdAPIErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::util::errors::APIError, +} +#[repr(C)] +/// A CResult_LSPSRequestIdAPIErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_liquidity::lsps0::ser::LSPSRequestId on success and a crate::lightning::util::errors::APIError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_LSPSRequestIdAPIErrorZ { + /// The contents of this CResult_LSPSRequestIdAPIErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_LSPSRequestIdAPIErrorZPtr, + /// Whether this CResult_LSPSRequestIdAPIErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_LSPSRequestIdAPIErrorZ in the success state. +pub extern "C" fn CResult_LSPSRequestIdAPIErrorZ_ok(o: crate::lightning_liquidity::lsps0::ser::LSPSRequestId) -> CResult_LSPSRequestIdAPIErrorZ { + CResult_LSPSRequestIdAPIErrorZ { + contents: CResult_LSPSRequestIdAPIErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_LSPSRequestIdAPIErrorZ in the error state. +pub extern "C" fn CResult_LSPSRequestIdAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_LSPSRequestIdAPIErrorZ { + CResult_LSPSRequestIdAPIErrorZ { + contents: CResult_LSPSRequestIdAPIErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_LSPSRequestIdAPIErrorZ_is_ok(o: &CResult_LSPSRequestIdAPIErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_LSPSRequestIdAPIErrorZ. +pub extern "C" fn CResult_LSPSRequestIdAPIErrorZ_free(_res: CResult_LSPSRequestIdAPIErrorZ) { } +impl Drop for CResult_LSPSRequestIdAPIErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_LSPSRequestIdAPIErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_LSPSRequestIdAPIErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_LSPSRequestIdAPIErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_LSPSRequestIdAPIErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_LSPSRequestIdAPIErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_LSPSRequestIdAPIErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_LSPSRequestIdAPIErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_LSPSRequestIdAPIErrorZ_clone(orig: &CResult_LSPSRequestIdAPIErrorZ) -> CResult_LSPSRequestIdAPIErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParamss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_LSPS2OpeningFeeParamsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_LSPS2OpeningFeeParamsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_LSPS2OpeningFeeParamsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_LSPS2OpeningFeeParamsZ_free(_res: CVec_LSPS2OpeningFeeParamsZ) { } +impl Drop for CVec_LSPS2OpeningFeeParamsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_LSPS2OpeningFeeParamsZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] /// The contents of CResult_OfferIdDecodeErrorZ pub union CResult_OfferIdDecodeErrorZPtr { /// A pointer to the contents in the success state. @@ -10977,43 +11226,6 @@ impl Clone for CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_clone(orig: &CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ) -> CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::Str or not -pub enum COption_StrZ { - /// When we're in this state, this COption_StrZ contains a crate::c_types::Str - Some(crate::c_types::Str), - /// When we're in this state, this COption_StrZ contains nothing - None -} -impl COption_StrZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::Str { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_StrZ containing a crate::c_types::Str -pub extern "C" fn COption_StrZ_some(o: crate::c_types::Str) -> COption_StrZ { - COption_StrZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_StrZ containing nothing -pub extern "C" fn COption_StrZ_none() -> COption_StrZ { - COption_StrZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::Str, if we are in the Some state -pub extern "C" fn COption_StrZ_free(_res: COption_StrZ) { } -#[no_mangle] -/// Creates a new COption_StrZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_StrZ_clone(orig: &COption_StrZ) -> COption_StrZ { Clone::clone(&orig) } -#[repr(C)] /// A dynamically-allocated array of crate::lightning::onion_message::messenger::Destinations of arbitrary size. /// This corresponds to std::vector in C++ pub struct CVec_DestinationZ { @@ -12579,6 +12791,44 @@ impl Clone for CResult_COption_APIErrorZDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_clone(orig: &CResult_COption_APIErrorZDecodeErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] +/// A dynamically-allocated array of crate::lightning_liquidity::lsps2::msgs::LSPS2RawOpeningFeeParamss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_LSPS2RawOpeningFeeParamsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning_liquidity::lsps2::msgs::LSPS2RawOpeningFeeParams, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_LSPS2RawOpeningFeeParamsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_liquidity::lsps2::msgs::LSPS2RawOpeningFeeParams] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_LSPS2RawOpeningFeeParamsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_LSPS2RawOpeningFeeParamsZ_free(_res: CVec_LSPS2RawOpeningFeeParamsZ) { } +impl Drop for CVec_LSPS2RawOpeningFeeParamsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +#[repr(C)] /// The contents of CResult_ChannelMonitorUpdateDecodeErrorZ pub union CResult_ChannelMonitorUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. @@ -14717,6 +14967,52 @@ impl Clone for CResult_CVec_u8ZIOErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_CVec_u8ZIOErrorZ_clone(orig: &CResult_CVec_u8ZIOErrorZ) -> CResult_CVec_u8ZIOErrorZ { Clone::clone(&orig) } #[repr(C)] +/// A dynamically-allocated array of crate::c_types::Strs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_StrZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::Str, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_StrZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Str] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_StrZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_StrZ_free(_res: CVec_StrZ) { } +impl Drop for CVec_StrZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_StrZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] /// The contents of CResult_CVec_StrZIOErrorZ pub union CResult_CVec_StrZIOErrorZPtr { /// A pointer to the contents in the success state. @@ -22461,6 +22757,194 @@ impl Drop for CVec_FutureZ { } } #[repr(C)] +/// The contents of CResult_RawLSPSMessageDecodeErrorZ +pub union CResult_RawLSPSMessageDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_liquidity::lsps0::ser::RawLSPSMessage, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_RawLSPSMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_liquidity::lsps0::ser::RawLSPSMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RawLSPSMessageDecodeErrorZ { + /// The contents of this CResult_RawLSPSMessageDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RawLSPSMessageDecodeErrorZPtr, + /// Whether this CResult_RawLSPSMessageDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_RawLSPSMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_RawLSPSMessageDecodeErrorZ_ok(o: crate::lightning_liquidity::lsps0::ser::RawLSPSMessage) -> CResult_RawLSPSMessageDecodeErrorZ { + CResult_RawLSPSMessageDecodeErrorZ { + contents: CResult_RawLSPSMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_RawLSPSMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_RawLSPSMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RawLSPSMessageDecodeErrorZ { + CResult_RawLSPSMessageDecodeErrorZ { + contents: CResult_RawLSPSMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_RawLSPSMessageDecodeErrorZ_is_ok(o: &CResult_RawLSPSMessageDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_RawLSPSMessageDecodeErrorZ. +pub extern "C" fn CResult_RawLSPSMessageDecodeErrorZ_free(_res: CResult_RawLSPSMessageDecodeErrorZ) { } +impl Drop for CResult_RawLSPSMessageDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_RawLSPSMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RawLSPSMessageDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RawLSPSMessageDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RawLSPSMessageDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RawLSPSMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RawLSPSMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RawLSPSMessageDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RawLSPSMessageDecodeErrorZ_clone(orig: &CResult_RawLSPSMessageDecodeErrorZ) -> CResult_RawLSPSMessageDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_LSPSDateTimeNoneZ +pub union CResult_LSPSDateTimeNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_liquidity::lsps0::ser::LSPSDateTime, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, +} +#[repr(C)] +/// A CResult_LSPSDateTimeNoneZ represents the result of a fallible operation, +/// containing a crate::lightning_liquidity::lsps0::ser::LSPSDateTime on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_LSPSDateTimeNoneZ { + /// The contents of this CResult_LSPSDateTimeNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_LSPSDateTimeNoneZPtr, + /// Whether this CResult_LSPSDateTimeNoneZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_LSPSDateTimeNoneZ in the success state. +pub extern "C" fn CResult_LSPSDateTimeNoneZ_ok(o: crate::lightning_liquidity::lsps0::ser::LSPSDateTime) -> CResult_LSPSDateTimeNoneZ { + CResult_LSPSDateTimeNoneZ { + contents: CResult_LSPSDateTimeNoneZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_LSPSDateTimeNoneZ in the error state. +pub extern "C" fn CResult_LSPSDateTimeNoneZ_err() -> CResult_LSPSDateTimeNoneZ { + CResult_LSPSDateTimeNoneZ { + contents: CResult_LSPSDateTimeNoneZPtr { + err: core::ptr::null_mut(), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_LSPSDateTimeNoneZ_is_ok(o: &CResult_LSPSDateTimeNoneZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_LSPSDateTimeNoneZ. +pub extern "C" fn CResult_LSPSDateTimeNoneZ_free(_res: CResult_LSPSDateTimeNoneZ) { } +impl Drop for CResult_LSPSDateTimeNoneZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + } + } +} +impl From> for CResult_LSPSDateTimeNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_LSPSDateTimeNoneZPtr { result } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_LSPSDateTimeNoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_LSPSDateTimeNoneZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_LSPSDateTimeNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_LSPSDateTimeNoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_LSPSDateTimeNoneZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_LSPSDateTimeNoneZ_clone(orig: &CResult_LSPSDateTimeNoneZ) -> CResult_LSPSDateTimeNoneZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_HeldHtlcAvailableDecodeErrorZ pub union CResult_HeldHtlcAvailableDecodeErrorZPtr { /// A pointer to the contents in the success state. @@ -24258,6 +24742,98 @@ impl Clone for CVec_TransactionZ { } } #[repr(C)] +/// The contents of CResult_u64NoneZ +pub union CResult_u64NoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut u64, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, +} +#[repr(C)] +/// A CResult_u64NoneZ represents the result of a fallible operation, +/// containing a u64 on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_u64NoneZ { + /// The contents of this CResult_u64NoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_u64NoneZPtr, + /// Whether this CResult_u64NoneZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_u64NoneZ in the success state. +pub extern "C" fn CResult_u64NoneZ_ok(o: u64) -> CResult_u64NoneZ { + CResult_u64NoneZ { + contents: CResult_u64NoneZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_u64NoneZ in the error state. +pub extern "C" fn CResult_u64NoneZ_err() -> CResult_u64NoneZ { + CResult_u64NoneZ { + contents: CResult_u64NoneZPtr { + err: core::ptr::null_mut(), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_u64NoneZ_is_ok(o: &CResult_u64NoneZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_u64NoneZ. +pub extern "C" fn CResult_u64NoneZ_free(_res: CResult_u64NoneZ) { } +impl Drop for CResult_u64NoneZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + } + } +} +impl From> for CResult_u64NoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_u64NoneZPtr { result } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_u64NoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_u64NoneZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_u64NoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_u64NoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_u64NoneZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_u64NoneZ_clone(orig: &CResult_u64NoneZ) -> CResult_u64NoneZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_FundingInfoDecodeErrorZ pub union CResult_FundingInfoDecodeErrorZPtr { /// A pointer to the contents in the success state. diff --git a/lightning-c-bindings/src/lib.rs b/lightning-c-bindings/src/lib.rs index a076598a..6f5c45c2 100644 --- a/lightning-c-bindings/src/lib.rs +++ b/lightning-c-bindings/src/lib.rs @@ -29,3 +29,4 @@ pub mod lightning_persister; pub mod lightning_background_processor; pub mod lightning_invoice; pub mod lightning_rapid_gossip_sync; +pub mod lightning_liquidity; diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs index bea1da69..69209013 100644 --- a/lightning-c-bindings/src/lightning/ln/msgs.rs +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -10141,6 +10141,8 @@ pub struct ChannelMessageHandler { /// May return an `Err(())` if the features the peer supports are not sufficient to communicate /// with us. Implementors should be somewhat conservative about doing so, however, as other /// message handlers may still wish to communicate with this peer. + /// + /// [`Self::peer_disconnected`] will not be called if `Err(())` is returned. pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ, /// Handle an incoming `channel_reestablish` message from the given peer. pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish), @@ -10804,6 +10806,8 @@ pub struct OnionMessageHandler { /// May return an `Err(())` if the features the peer supports are not sufficient to communicate /// with us. Implementors should be somewhat conservative about doing so, however, as other /// message handlers may still wish to communicate with this peer. + /// + /// [`Self::peer_disconnected`] will not be called if `Err(())` is returned. pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ, /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to /// drop and refuse to forward onion messages to this peer. diff --git a/lightning-c-bindings/src/lightning/ln/peer_handler.rs b/lightning-c-bindings/src/lightning/ln/peer_handler.rs index 699df6bb..4f512759 100644 --- a/lightning-c-bindings/src/lightning/ln/peer_handler.rs +++ b/lightning-c-bindings/src/lightning/ln/peer_handler.rs @@ -51,6 +51,8 @@ pub struct CustomMessageHandler { /// May return an `Err(())` if the features the peer supports are not sufficient to communicate /// with us. Implementors should be somewhat conservative about doing so, however, as other /// message handlers may still wish to communicate with this peer. + /// + /// [`Self::peer_disconnected`] will not be called if `Err(())` is returned. pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ, /// Gets the node feature flags which this handler itself supports. All available handlers are /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] diff --git a/lightning-c-bindings/src/lightning/offers/invoice.rs b/lightning-c-bindings/src/lightning/offers/invoice.rs index d90633ab..18dd85cb 100644 --- a/lightning-c-bindings/src/lightning/offers/invoice.rs +++ b/lightning-c-bindings/src/lightning/offers/invoice.rs @@ -657,9 +657,9 @@ pub extern "C" fn UnsignedBolt12Invoice_is_expired(this_arg: &crate::lightning:: /// least-preferred. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_fallbacks(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_StrZ { +pub extern "C" fn UnsignedBolt12Invoice_fallbacks(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_AddressZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fallbacks(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { alloc::string::ToString::to_string(&item).into() }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::Address::from_rust(&item) }); }; local_ret.into() } @@ -967,9 +967,9 @@ pub extern "C" fn Bolt12Invoice_is_expired(this_arg: &crate::lightning::offers:: /// least-preferred. #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_fallbacks(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_StrZ { +pub extern "C" fn Bolt12Invoice_fallbacks(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_AddressZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fallbacks(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { alloc::string::ToString::to_string(&item).into() }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::Address::from_rust(&item) }); }; local_ret.into() } diff --git a/lightning-c-bindings/src/lightning_invoice/mod.rs b/lightning-c-bindings/src/lightning_invoice/mod.rs index 08141d4a..d9ebaa5b 100644 --- a/lightning-c-bindings/src/lightning_invoice/mod.rs +++ b/lightning-c-bindings/src/lightning_invoice/mod.rs @@ -398,6 +398,18 @@ pub static DEFAULT_EXPIRY_TIME: u64 = lightning_invoice::DEFAULT_EXPIRY_TIME; #[no_mangle] pub static DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA: u64 = lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA; +/// lightning-invoice will reject BOLT11 invoices that are longer than 7089 bytes. +/// +/// ### Rationale +/// +/// This value matches LND's implementation, which was chosen to be \"the max number +/// of bytes that can fit in a QR code\". LND's rationale is technically incorrect +/// as QR codes actually have a max capacity of 7089 _numeric_ characters and only +/// support up to 4296 all-uppercase alphanumeric characters. However, ecosystem-wide +/// consistency is more important. + +#[no_mangle] +pub static MAX_LENGTH: usize = lightning_invoice::MAX_LENGTH; use lightning_invoice::Bolt11Invoice as nativeBolt11InvoiceImport; pub(crate) type nativeBolt11Invoice = nativeBolt11InvoiceImport; @@ -2676,9 +2688,9 @@ pub extern "C" fn Bolt11Invoice_min_final_cltv_expiry_delta(this_arg: &crate::li /// Returns a list of all fallback addresses as [`Address`]es #[must_use] #[no_mangle] -pub extern "C" fn Bolt11Invoice_fallback_addresses(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_StrZ { +pub extern "C" fn Bolt11Invoice_fallback_addresses(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_AddressZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fallback_addresses(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { alloc::string::ToString::to_string(&item).into() }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::Address::from_rust(&item) }); }; local_ret.into() } diff --git a/lightning-c-bindings/src/lightning_liquidity/events.rs b/lightning-c-bindings/src/lightning_liquidity/events.rs new file mode 100644 index 00000000..82ffac2c --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/events.rs @@ -0,0 +1,208 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Events are surfaced by the library to indicate some action must be taken +//! by the end-user. +//! +//! Because we don't have a built-in runtime, it's up to the end-user to poll +//! [`LiquidityManager::get_and_clear_pending_events`] to receive events. +//! +//! [`LiquidityManager::get_and_clear_pending_events`]: crate::LiquidityManager::get_and_clear_pending_events + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// The maximum queue size we allow before starting to drop events. + +#[no_mangle] +pub static MAX_EVENT_QUEUE_SIZE: usize = lightning_liquidity::events::MAX_EVENT_QUEUE_SIZE; +/// An event which you should probably take some action in response to. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LiquidityEvent { + /// An LSPS0 client event. + LSPS0Client( + crate::lightning_liquidity::lsps0::event::LSPS0ClientEvent), + /// An LSPS1 (Channel Request) client event. + LSPS1Client( + crate::lightning_liquidity::lsps1::event::LSPS1ClientEvent), + /// An LSPS2 (JIT Channel) client event. + LSPS2Client( + crate::lightning_liquidity::lsps2::event::LSPS2ClientEvent), + /// An LSPS2 (JIT Channel) server event. + LSPS2Service( + crate::lightning_liquidity::lsps2::event::LSPS2ServiceEvent), +} +use lightning_liquidity::events::LiquidityEvent as LiquidityEventImport; +pub(crate) type nativeLiquidityEvent = LiquidityEventImport; + +impl LiquidityEvent { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLiquidityEvent { + match self { + LiquidityEvent::LSPS0Client (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLiquidityEvent::LSPS0Client ( + a_nonref.into_native(), + ) + }, + LiquidityEvent::LSPS1Client (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLiquidityEvent::LSPS1Client ( + a_nonref.into_native(), + ) + }, + LiquidityEvent::LSPS2Client (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLiquidityEvent::LSPS2Client ( + a_nonref.into_native(), + ) + }, + LiquidityEvent::LSPS2Service (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLiquidityEvent::LSPS2Service ( + a_nonref.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLiquidityEvent { + match self { + LiquidityEvent::LSPS0Client (mut a, ) => { + nativeLiquidityEvent::LSPS0Client ( + a.into_native(), + ) + }, + LiquidityEvent::LSPS1Client (mut a, ) => { + nativeLiquidityEvent::LSPS1Client ( + a.into_native(), + ) + }, + LiquidityEvent::LSPS2Client (mut a, ) => { + nativeLiquidityEvent::LSPS2Client ( + a.into_native(), + ) + }, + LiquidityEvent::LSPS2Service (mut a, ) => { + nativeLiquidityEvent::LSPS2Service ( + a.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LiquidityEventImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLiquidityEvent) }; + match native { + nativeLiquidityEvent::LSPS0Client (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LiquidityEvent::LSPS0Client ( + crate::lightning_liquidity::lsps0::event::LSPS0ClientEvent::native_into(a_nonref), + ) + }, + nativeLiquidityEvent::LSPS1Client (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LiquidityEvent::LSPS1Client ( + crate::lightning_liquidity::lsps1::event::LSPS1ClientEvent::native_into(a_nonref), + ) + }, + nativeLiquidityEvent::LSPS2Client (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LiquidityEvent::LSPS2Client ( + crate::lightning_liquidity::lsps2::event::LSPS2ClientEvent::native_into(a_nonref), + ) + }, + nativeLiquidityEvent::LSPS2Service (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LiquidityEvent::LSPS2Service ( + crate::lightning_liquidity::lsps2::event::LSPS2ServiceEvent::native_into(a_nonref), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLiquidityEvent) -> Self { + match native { + nativeLiquidityEvent::LSPS0Client (mut a, ) => { + LiquidityEvent::LSPS0Client ( + crate::lightning_liquidity::lsps0::event::LSPS0ClientEvent::native_into(a), + ) + }, + nativeLiquidityEvent::LSPS1Client (mut a, ) => { + LiquidityEvent::LSPS1Client ( + crate::lightning_liquidity::lsps1::event::LSPS1ClientEvent::native_into(a), + ) + }, + nativeLiquidityEvent::LSPS2Client (mut a, ) => { + LiquidityEvent::LSPS2Client ( + crate::lightning_liquidity::lsps2::event::LSPS2ClientEvent::native_into(a), + ) + }, + nativeLiquidityEvent::LSPS2Service (mut a, ) => { + LiquidityEvent::LSPS2Service ( + crate::lightning_liquidity::lsps2::event::LSPS2ServiceEvent::native_into(a), + ) + }, + } + } +} +/// Frees any resources used by the LiquidityEvent +#[no_mangle] +pub extern "C" fn LiquidityEvent_free(this_ptr: LiquidityEvent) { } +/// Creates a copy of the LiquidityEvent +#[no_mangle] +pub extern "C" fn LiquidityEvent_clone(orig: &LiquidityEvent) -> LiquidityEvent { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LiquidityEvent_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LiquidityEvent)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LiquidityEvent_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LiquidityEvent) }; +} +#[no_mangle] +/// Utility method to constructs a new LSPS0Client-variant LiquidityEvent +pub extern "C" fn LiquidityEvent_lsps0_client(a: crate::lightning_liquidity::lsps0::event::LSPS0ClientEvent) -> LiquidityEvent { + LiquidityEvent::LSPS0Client(a, ) +} +#[no_mangle] +/// Utility method to constructs a new LSPS1Client-variant LiquidityEvent +pub extern "C" fn LiquidityEvent_lsps1_client(a: crate::lightning_liquidity::lsps1::event::LSPS1ClientEvent) -> LiquidityEvent { + LiquidityEvent::LSPS1Client(a, ) +} +#[no_mangle] +/// Utility method to constructs a new LSPS2Client-variant LiquidityEvent +pub extern "C" fn LiquidityEvent_lsps2_client(a: crate::lightning_liquidity::lsps2::event::LSPS2ClientEvent) -> LiquidityEvent { + LiquidityEvent::LSPS2Client(a, ) +} +#[no_mangle] +/// Utility method to constructs a new LSPS2Service-variant LiquidityEvent +pub extern "C" fn LiquidityEvent_lsps2_service(a: crate::lightning_liquidity::lsps2::event::LSPS2ServiceEvent) -> LiquidityEvent { + LiquidityEvent::LSPS2Service(a, ) +} +/// Get a string which allows debug introspection of a LiquidityEvent object +pub extern "C" fn LiquidityEvent_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::events::LiquidityEvent }).into()} +/// Checks if two LiquidityEvents contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LiquidityEvent_eq(a: &LiquidityEvent, b: &LiquidityEvent) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps0/client.rs b/lightning-c-bindings/src/lightning_liquidity/lsps0/client.rs new file mode 100644 index 00000000..f7006b3e --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps0/client.rs @@ -0,0 +1,93 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Contains the main bLIP-50 / LSPS0 client-side object, [`LSPS0ClientHandler`]. +//! +//! Please refer to the [bLIP-50 / LSPS0 +//! specifcation](https://github.com/lightning/blips/blob/master/blip-0050.md) for more +//! information. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning_liquidity::lsps0::client::LSPS0ClientHandler as nativeLSPS0ClientHandlerImport; +pub(crate) type nativeLSPS0ClientHandler = nativeLSPS0ClientHandlerImport; + +/// A message handler capable of sending and handling bLIP-50 / LSPS0 messages. +#[must_use] +#[repr(C)] +pub struct LSPS0ClientHandler { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS0ClientHandler, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS0ClientHandler { + type Target = nativeLSPS0ClientHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS0ClientHandler { } +unsafe impl core::marker::Sync for LSPS0ClientHandler { } +impl Drop for LSPS0ClientHandler { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS0ClientHandler>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS0ClientHandler, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS0ClientHandler_free(this_obj: LSPS0ClientHandler) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0ClientHandler_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS0ClientHandler) }; +} +#[allow(unused)] +impl LSPS0ClientHandler { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS0ClientHandler { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS0ClientHandler { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS0ClientHandler { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Calls bLIP-50 / LSPS0's `list_protocols`. +/// +/// Please refer to the [bLIP-50 / LSPS0 +/// specifcation](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) +/// for more information. +#[no_mangle] +pub extern "C" fn LSPS0ClientHandler_list_protocols(this_arg: &crate::lightning_liquidity::lsps0::client::LSPS0ClientHandler, mut counterparty_node_id: crate::c_types::PublicKey) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_protocols(&counterparty_node_id.into_rust()) +} + diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps0/event.rs b/lightning-c-bindings/src/lightning_liquidity/lsps0/event.rs new file mode 100644 index 00000000..8f76d916 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps0/event.rs @@ -0,0 +1,125 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Contains bLIP-50 / LSPS0 event types. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// An event which an bLIP-50 / LSPS0 client may want to take some action in response to. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS0ClientEvent { + /// Information from the LSP about the protocols they support. + ListProtocolsResponse { + /// The node id of the LSP. + counterparty_node_id: crate::c_types::PublicKey, + /// A list of supported protocols. + protocols: crate::c_types::derived::CVec_u16Z, + }, +} +use lightning_liquidity::lsps0::event::LSPS0ClientEvent as LSPS0ClientEventImport; +pub(crate) type nativeLSPS0ClientEvent = LSPS0ClientEventImport; + +impl LSPS0ClientEvent { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS0ClientEvent { + match self { + LSPS0ClientEvent::ListProtocolsResponse {ref counterparty_node_id, ref protocols, } => { + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut protocols_nonref = Clone::clone(protocols); + let mut local_protocols_nonref = Vec::new(); for mut item in protocols_nonref.into_rust().drain(..) { local_protocols_nonref.push( { item }); }; + nativeLSPS0ClientEvent::ListProtocolsResponse { + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + protocols: local_protocols_nonref, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS0ClientEvent { + match self { + LSPS0ClientEvent::ListProtocolsResponse {mut counterparty_node_id, mut protocols, } => { + let mut local_protocols = Vec::new(); for mut item in protocols.into_rust().drain(..) { local_protocols.push( { item }); }; + nativeLSPS0ClientEvent::ListProtocolsResponse { + counterparty_node_id: counterparty_node_id.into_rust(), + protocols: local_protocols, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS0ClientEventImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS0ClientEvent) }; + match native { + nativeLSPS0ClientEvent::ListProtocolsResponse {ref counterparty_node_id, ref protocols, } => { + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut protocols_nonref = Clone::clone(protocols); + let mut local_protocols_nonref = Vec::new(); for mut item in protocols_nonref.drain(..) { local_protocols_nonref.push( { item }); }; + LSPS0ClientEvent::ListProtocolsResponse { + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + protocols: local_protocols_nonref.into(), + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS0ClientEvent) -> Self { + match native { + nativeLSPS0ClientEvent::ListProtocolsResponse {mut counterparty_node_id, mut protocols, } => { + let mut local_protocols = Vec::new(); for mut item in protocols.drain(..) { local_protocols.push( { item }); }; + LSPS0ClientEvent::ListProtocolsResponse { + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + protocols: local_protocols.into(), + } + }, + } + } +} +/// Frees any resources used by the LSPS0ClientEvent +#[no_mangle] +pub extern "C" fn LSPS0ClientEvent_free(this_ptr: LSPS0ClientEvent) { } +/// Creates a copy of the LSPS0ClientEvent +#[no_mangle] +pub extern "C" fn LSPS0ClientEvent_clone(orig: &LSPS0ClientEvent) -> LSPS0ClientEvent { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0ClientEvent_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS0ClientEvent)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0ClientEvent_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS0ClientEvent) }; +} +#[no_mangle] +/// Utility method to constructs a new ListProtocolsResponse-variant LSPS0ClientEvent +pub extern "C" fn LSPS0ClientEvent_list_protocols_response(counterparty_node_id: crate::c_types::PublicKey, protocols: crate::c_types::derived::CVec_u16Z) -> LSPS0ClientEvent { + LSPS0ClientEvent::ListProtocolsResponse { + counterparty_node_id, + protocols, + } +} +/// Get a string which allows debug introspection of a LSPS0ClientEvent object +pub extern "C" fn LSPS0ClientEvent_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps0::event::LSPS0ClientEvent }).into()} +/// Checks if two LSPS0ClientEvents contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS0ClientEvent_eq(a: &LSPS0ClientEvent, b: &LSPS0ClientEvent) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps0/mod.rs b/lightning-c-bindings/src/lightning_liquidity/lsps0/mod.rs new file mode 100644 index 00000000..d8911071 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps0/mod.rs @@ -0,0 +1,24 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Types and primitives that implement the bLIP-50 / LSPS0: Transport Layer specification. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +pub mod client; +pub mod event; +pub mod msgs; +pub mod ser; +pub mod service; diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps0/msgs.rs b/lightning-c-bindings/src/lightning_liquidity/lsps0/msgs.rs new file mode 100644 index 00000000..b6ea4cd5 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps0/msgs.rs @@ -0,0 +1,601 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Message, request, and other primitive types used to implement LSPS0. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsRequest as nativeLSPS0ListProtocolsRequestImport; +pub(crate) type nativeLSPS0ListProtocolsRequest = nativeLSPS0ListProtocolsRequestImport; + +/// A `list_protocols` request. +/// +/// Please refer to the [bLIP-50 / LSPS0 +/// specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) +/// for more information. +#[must_use] +#[repr(C)] +pub struct LSPS0ListProtocolsRequest { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS0ListProtocolsRequest, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS0ListProtocolsRequest { + type Target = nativeLSPS0ListProtocolsRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS0ListProtocolsRequest { } +unsafe impl core::marker::Sync for LSPS0ListProtocolsRequest { } +impl Drop for LSPS0ListProtocolsRequest { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS0ListProtocolsRequest>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS0ListProtocolsRequest, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS0ListProtocolsRequest_free(this_obj: LSPS0ListProtocolsRequest) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0ListProtocolsRequest_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS0ListProtocolsRequest) }; +} +#[allow(unused)] +impl LSPS0ListProtocolsRequest { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS0ListProtocolsRequest { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS0ListProtocolsRequest { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS0ListProtocolsRequest { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Constructs a new LSPS0ListProtocolsRequest given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS0ListProtocolsRequest_new() -> LSPS0ListProtocolsRequest { + LSPS0ListProtocolsRequest { inner: ObjOps::heap_alloc(nativeLSPS0ListProtocolsRequest { + }), is_owned: true } +} +impl Clone for LSPS0ListProtocolsRequest { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS0ListProtocolsRequest>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0ListProtocolsRequest_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS0ListProtocolsRequest)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS0ListProtocolsRequest +pub extern "C" fn LSPS0ListProtocolsRequest_clone(orig: &LSPS0ListProtocolsRequest) -> LSPS0ListProtocolsRequest { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS0ListProtocolsRequest object +pub extern "C" fn LSPS0ListProtocolsRequest_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsRequest }).into()} +/// Checks if two LSPS0ListProtocolsRequests contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS0ListProtocolsRequest_eq(a: &LSPS0ListProtocolsRequest, b: &LSPS0ListProtocolsRequest) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsResponse as nativeLSPS0ListProtocolsResponseImport; +pub(crate) type nativeLSPS0ListProtocolsResponse = nativeLSPS0ListProtocolsResponseImport; + +/// A response to a `list_protocols` request. +/// +/// Please refer to the [bLIP-50 / LSPS0 +/// specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) +/// for more information. +#[must_use] +#[repr(C)] +pub struct LSPS0ListProtocolsResponse { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS0ListProtocolsResponse, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS0ListProtocolsResponse { + type Target = nativeLSPS0ListProtocolsResponse; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS0ListProtocolsResponse { } +unsafe impl core::marker::Sync for LSPS0ListProtocolsResponse { } +impl Drop for LSPS0ListProtocolsResponse { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS0ListProtocolsResponse>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS0ListProtocolsResponse, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS0ListProtocolsResponse_free(this_obj: LSPS0ListProtocolsResponse) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0ListProtocolsResponse_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS0ListProtocolsResponse) }; +} +#[allow(unused)] +impl LSPS0ListProtocolsResponse { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS0ListProtocolsResponse { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS0ListProtocolsResponse { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS0ListProtocolsResponse { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// A list of supported protocols. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn LSPS0ListProtocolsResponse_get_protocols(this_ptr: &LSPS0ListProtocolsResponse) -> crate::c_types::derived::CVec_u16Z { + let mut inner_val = this_ptr.get_native_mut_ref().protocols.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); }; + local_inner_val.into() +} +/// A list of supported protocols. +#[no_mangle] +pub extern "C" fn LSPS0ListProtocolsResponse_set_protocols(this_ptr: &mut LSPS0ListProtocolsResponse, mut val: crate::c_types::derived::CVec_u16Z) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.protocols = local_val; +} +/// Constructs a new LSPS0ListProtocolsResponse given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS0ListProtocolsResponse_new(mut protocols_arg: crate::c_types::derived::CVec_u16Z) -> LSPS0ListProtocolsResponse { + let mut local_protocols_arg = Vec::new(); for mut item in protocols_arg.into_rust().drain(..) { local_protocols_arg.push( { item }); }; + LSPS0ListProtocolsResponse { inner: ObjOps::heap_alloc(nativeLSPS0ListProtocolsResponse { + protocols: local_protocols_arg, + }), is_owned: true } +} +impl Clone for LSPS0ListProtocolsResponse { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS0ListProtocolsResponse>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0ListProtocolsResponse_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS0ListProtocolsResponse)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS0ListProtocolsResponse +pub extern "C" fn LSPS0ListProtocolsResponse_clone(orig: &LSPS0ListProtocolsResponse) -> LSPS0ListProtocolsResponse { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS0ListProtocolsResponse object +pub extern "C" fn LSPS0ListProtocolsResponse_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsResponse }).into()} +/// Checks if two LSPS0ListProtocolsResponses contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS0ListProtocolsResponse_eq(a: &LSPS0ListProtocolsResponse, b: &LSPS0ListProtocolsResponse) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// An bLIP-50 / LSPS0 protocol request. +/// +/// Please refer to the [bLIP-50 / LSPS0 +/// specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) +/// for more information. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS0Request { + /// A request calling `list_protocols`. + ListProtocols( + crate::lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsRequest), +} +use lightning_liquidity::lsps0::msgs::LSPS0Request as LSPS0RequestImport; +pub(crate) type nativeLSPS0Request = LSPS0RequestImport; + +impl LSPS0Request { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS0Request { + match self { + LSPS0Request::ListProtocols (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS0Request::ListProtocols ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS0Request { + match self { + LSPS0Request::ListProtocols (mut a, ) => { + nativeLSPS0Request::ListProtocols ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS0RequestImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS0Request) }; + match native { + nativeLSPS0Request::ListProtocols (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS0Request::ListProtocols ( + crate::lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsRequest { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS0Request) -> Self { + match native { + nativeLSPS0Request::ListProtocols (mut a, ) => { + LSPS0Request::ListProtocols ( + crate::lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsRequest { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the LSPS0Request +#[no_mangle] +pub extern "C" fn LSPS0Request_free(this_ptr: LSPS0Request) { } +/// Creates a copy of the LSPS0Request +#[no_mangle] +pub extern "C" fn LSPS0Request_clone(orig: &LSPS0Request) -> LSPS0Request { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0Request_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS0Request)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0Request_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS0Request) }; +} +#[no_mangle] +/// Utility method to constructs a new ListProtocols-variant LSPS0Request +pub extern "C" fn LSPS0Request_list_protocols(a: crate::lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsRequest) -> LSPS0Request { + LSPS0Request::ListProtocols(a, ) +} +/// Get a string which allows debug introspection of a LSPS0Request object +pub extern "C" fn LSPS0Request_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps0::msgs::LSPS0Request }).into()} +/// Checks if two LSPS0Requests contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS0Request_eq(a: &LSPS0Request, b: &LSPS0Request) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +/// Returns the method name associated with the given request variant. +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS0Request_method(this_arg: &crate::lightning_liquidity::lsps0::msgs::LSPS0Request) -> crate::c_types::Str { + let mut ret = this_arg.to_native().method(); + ret.into() +} + +/// An bLIP-50 / LSPS0 protocol request. +/// +/// Please refer to the [bLIP-50 / LSPS0 +/// specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) +/// for more information. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS0Response { + /// A response to a `list_protocols` request. + ListProtocols( + crate::lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsResponse), + /// An error response to a `list_protocols` request. + ListProtocolsError( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError), +} +use lightning_liquidity::lsps0::msgs::LSPS0Response as LSPS0ResponseImport; +pub(crate) type nativeLSPS0Response = LSPS0ResponseImport; + +impl LSPS0Response { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS0Response { + match self { + LSPS0Response::ListProtocols (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS0Response::ListProtocols ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS0Response::ListProtocolsError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS0Response::ListProtocolsError ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS0Response { + match self { + LSPS0Response::ListProtocols (mut a, ) => { + nativeLSPS0Response::ListProtocols ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS0Response::ListProtocolsError (mut a, ) => { + nativeLSPS0Response::ListProtocolsError ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS0ResponseImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS0Response) }; + match native { + nativeLSPS0Response::ListProtocols (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS0Response::ListProtocols ( + crate::lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsResponse { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS0Response::ListProtocolsError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS0Response::ListProtocolsError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS0Response) -> Self { + match native { + nativeLSPS0Response::ListProtocols (mut a, ) => { + LSPS0Response::ListProtocols ( + crate::lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsResponse { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS0Response::ListProtocolsError (mut a, ) => { + LSPS0Response::ListProtocolsError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the LSPS0Response +#[no_mangle] +pub extern "C" fn LSPS0Response_free(this_ptr: LSPS0Response) { } +/// Creates a copy of the LSPS0Response +#[no_mangle] +pub extern "C" fn LSPS0Response_clone(orig: &LSPS0Response) -> LSPS0Response { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0Response_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS0Response)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0Response_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS0Response) }; +} +#[no_mangle] +/// Utility method to constructs a new ListProtocols-variant LSPS0Response +pub extern "C" fn LSPS0Response_list_protocols(a: crate::lightning_liquidity::lsps0::msgs::LSPS0ListProtocolsResponse) -> LSPS0Response { + LSPS0Response::ListProtocols(a, ) +} +#[no_mangle] +/// Utility method to constructs a new ListProtocolsError-variant LSPS0Response +pub extern "C" fn LSPS0Response_list_protocols_error(a: crate::lightning_liquidity::lsps0::ser::LSPSResponseError) -> LSPS0Response { + LSPS0Response::ListProtocolsError(a, ) +} +/// Get a string which allows debug introspection of a LSPS0Response object +pub extern "C" fn LSPS0Response_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps0::msgs::LSPS0Response }).into()} +/// Checks if two LSPS0Responses contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS0Response_eq(a: &LSPS0Response, b: &LSPS0Response) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +/// An bLIP-50 / LSPS0 protocol message. +/// +/// Please refer to the [bLIP-50 / LSPS0 +/// specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) +/// for more information. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS0Message { + /// A request variant. + Request( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + crate::lightning_liquidity::lsps0::msgs::LSPS0Request), + /// A response variant. + Response( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + crate::lightning_liquidity::lsps0::msgs::LSPS0Response), +} +use lightning_liquidity::lsps0::msgs::LSPS0Message as LSPS0MessageImport; +pub(crate) type nativeLSPS0Message = LSPS0MessageImport; + +impl LSPS0Message { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS0Message { + match self { + LSPS0Message::Request (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + nativeLSPS0Message::Request ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + b_nonref.into_native(), + ) + }, + LSPS0Message::Response (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + nativeLSPS0Message::Response ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + b_nonref.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS0Message { + match self { + LSPS0Message::Request (mut a, mut b, ) => { + nativeLSPS0Message::Request ( + *unsafe { Box::from_raw(a.take_inner()) }, + b.into_native(), + ) + }, + LSPS0Message::Response (mut a, mut b, ) => { + nativeLSPS0Message::Response ( + *unsafe { Box::from_raw(a.take_inner()) }, + b.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS0MessageImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS0Message) }; + match native { + nativeLSPS0Message::Request (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + LSPS0Message::Request ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + crate::lightning_liquidity::lsps0::msgs::LSPS0Request::native_into(b_nonref), + ) + }, + nativeLSPS0Message::Response (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + LSPS0Message::Response ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + crate::lightning_liquidity::lsps0::msgs::LSPS0Response::native_into(b_nonref), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS0Message) -> Self { + match native { + nativeLSPS0Message::Request (mut a, mut b, ) => { + LSPS0Message::Request ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a), is_owned: true }, + crate::lightning_liquidity::lsps0::msgs::LSPS0Request::native_into(b), + ) + }, + nativeLSPS0Message::Response (mut a, mut b, ) => { + LSPS0Message::Response ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a), is_owned: true }, + crate::lightning_liquidity::lsps0::msgs::LSPS0Response::native_into(b), + ) + }, + } + } +} +/// Frees any resources used by the LSPS0Message +#[no_mangle] +pub extern "C" fn LSPS0Message_free(this_ptr: LSPS0Message) { } +/// Creates a copy of the LSPS0Message +#[no_mangle] +pub extern "C" fn LSPS0Message_clone(orig: &LSPS0Message) -> LSPS0Message { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0Message_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS0Message)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0Message_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS0Message) }; +} +#[no_mangle] +/// Utility method to constructs a new Request-variant LSPS0Message +pub extern "C" fn LSPS0Message_request(a: crate::lightning_liquidity::lsps0::ser::LSPSRequestId,b: crate::lightning_liquidity::lsps0::msgs::LSPS0Request) -> LSPS0Message { + LSPS0Message::Request(a, b, ) +} +#[no_mangle] +/// Utility method to constructs a new Response-variant LSPS0Message +pub extern "C" fn LSPS0Message_response(a: crate::lightning_liquidity::lsps0::ser::LSPSRequestId,b: crate::lightning_liquidity::lsps0::msgs::LSPS0Response) -> LSPS0Message { + LSPS0Message::Response(a, b, ) +} +/// Get a string which allows debug introspection of a LSPS0Message object +pub extern "C" fn LSPS0Message_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps0::msgs::LSPS0Message }).into()} +/// Checks if two LSPS0Messages contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS0Message_eq(a: &LSPS0Message, b: &LSPS0Message) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps0/ser.rs b/lightning-c-bindings/src/lightning_liquidity/lsps0/ser.rs new file mode 100644 index 00000000..e858272a --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps0/ser.rs @@ -0,0 +1,803 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Contains basic data types that allow for the (de-)seralization of LSPS messages in the JSON-RPC 2.0 format. +//! +//! Please refer to the [bLIP-50 / LSPS0 +//! specification](https://github.com/lightning/blips/blob/master/blip-0050.md) for more +//! information. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// The Lightning message type id for LSPS messages. + +#[no_mangle] +pub static LSPS_MESSAGE_TYPE_ID: u16 = lightning_liquidity::lsps0::ser::LSPS_MESSAGE_TYPE_ID; + +use lightning_liquidity::lsps0::ser::RawLSPSMessage as nativeRawLSPSMessageImport; +pub(crate) type nativeRawLSPSMessage = nativeRawLSPSMessageImport; + +/// Lightning message type used by LSPS protocols. +#[must_use] +#[repr(C)] +pub struct RawLSPSMessage { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeRawLSPSMessage, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for RawLSPSMessage { + type Target = nativeRawLSPSMessage; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RawLSPSMessage { } +unsafe impl core::marker::Sync for RawLSPSMessage { } +impl Drop for RawLSPSMessage { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRawLSPSMessage>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the RawLSPSMessage, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RawLSPSMessage_free(this_obj: RawLSPSMessage) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RawLSPSMessage_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRawLSPSMessage) }; +} +#[allow(unused)] +impl RawLSPSMessage { + pub(crate) fn get_native_ref(&self) -> &'static nativeRawLSPSMessage { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRawLSPSMessage { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeRawLSPSMessage { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The raw string payload that holds the actual message. +#[no_mangle] +pub extern "C" fn RawLSPSMessage_get_payload(this_ptr: &RawLSPSMessage) -> crate::c_types::Str { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payload; + inner_val.as_str().into() +} +/// The raw string payload that holds the actual message. +#[no_mangle] +pub extern "C" fn RawLSPSMessage_set_payload(this_ptr: &mut RawLSPSMessage, mut val: crate::c_types::Str) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payload = val.into_string(); +} +/// Constructs a new RawLSPSMessage given each field +#[must_use] +#[no_mangle] +pub extern "C" fn RawLSPSMessage_new(mut payload_arg: crate::c_types::Str) -> RawLSPSMessage { + RawLSPSMessage { inner: ObjOps::heap_alloc(nativeRawLSPSMessage { + payload: payload_arg.into_string(), + }), is_owned: true } +} +impl Clone for RawLSPSMessage { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRawLSPSMessage>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RawLSPSMessage_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRawLSPSMessage)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RawLSPSMessage +pub extern "C" fn RawLSPSMessage_clone(orig: &RawLSPSMessage) -> RawLSPSMessage { + orig.clone() +} +/// Get a string which allows debug introspection of a RawLSPSMessage object +pub extern "C" fn RawLSPSMessage_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps0::ser::RawLSPSMessage }).into()} +/// Checks if two RawLSPSMessages contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn RawLSPSMessage_eq(a: &RawLSPSMessage, b: &RawLSPSMessage) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +#[no_mangle] +/// Serialize the RawLSPSMessage object into a byte array which can be read by RawLSPSMessage_read +pub extern "C" fn RawLSPSMessage_write(obj: &crate::lightning_liquidity::lsps0::ser::RawLSPSMessage) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn RawLSPSMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_liquidity::lsps0::ser::nativeRawLSPSMessage) }) +} +#[no_mangle] +/// Read a RawLSPSMessage from a byte array, created by RawLSPSMessage_write +pub extern "C" fn RawLSPSMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RawLSPSMessageDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_liquidity::lsps0::ser::RawLSPSMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +impl From for crate::lightning::ln::wire::Type { + fn from(obj: nativeRawLSPSMessage) -> Self { + let rust_obj = crate::lightning_liquidity::lsps0::ser::RawLSPSMessage { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = RawLSPSMessage_as_Type(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(RawLSPSMessage_free_void); + ret + } +} +/// Constructs a new Type which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned Type must be freed before this_arg is +#[no_mangle] +pub extern "C" fn RawLSPSMessage_as_Type(this_arg: &RawLSPSMessage) -> crate::lightning::ln::wire::Type { + crate::lightning::ln::wire::Type { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + type_id: RawLSPSMessage_Type_type_id, + debug_str: RawLSPSMessage_debug_str_void, + write: RawLSPSMessage_write_void, + cloned: Some(Type_RawLSPSMessage_cloned), + } +} + +#[must_use] +extern "C" fn RawLSPSMessage_Type_type_id(this_arg: *const c_void) -> u16 { + let mut ret = ::type_id(unsafe { &mut *(this_arg as *mut nativeRawLSPSMessage) }, ); + ret +} +extern "C" fn Type_RawLSPSMessage_cloned(new_obj: &mut crate::lightning::ln::wire::Type) { + new_obj.this_arg = RawLSPSMessage_clone_void(new_obj.this_arg); + new_obj.free = Some(RawLSPSMessage_free_void); +} + + +use lightning_liquidity::lsps0::ser::LSPSRequestId as nativeLSPSRequestIdImport; +pub(crate) type nativeLSPSRequestId = nativeLSPSRequestIdImport; + +/// A JSON-RPC request's `id`. +/// +/// Please refer to the [JSON-RPC 2.0 specification](https://www.jsonrpc.org/specification#request_object) for +/// more information. +#[must_use] +#[repr(C)] +pub struct LSPSRequestId { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPSRequestId, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPSRequestId { + type Target = nativeLSPSRequestId; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPSRequestId { } +unsafe impl core::marker::Sync for LSPSRequestId { } +impl Drop for LSPSRequestId { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPSRequestId>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPSRequestId, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPSRequestId_free(this_obj: LSPSRequestId) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPSRequestId_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPSRequestId) }; +} +#[allow(unused)] +impl LSPSRequestId { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPSRequestId { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPSRequestId { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPSRequestId { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn LSPSRequestId_get_a(this_ptr: &LSPSRequestId) -> crate::c_types::Str { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + inner_val.as_str().into() +} +#[no_mangle] +pub extern "C" fn LSPSRequestId_set_a(this_ptr: &mut LSPSRequestId, mut val: crate::c_types::Str) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_string(); +} +/// Constructs a new LSPSRequestId given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPSRequestId_new(mut a_arg: crate::c_types::Str) -> LSPSRequestId { + LSPSRequestId { inner: ObjOps::heap_alloc(lightning_liquidity::lsps0::ser::LSPSRequestId ( + a_arg.into_string(), + )), is_owned: true } +} +impl Clone for LSPSRequestId { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPSRequestId>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPSRequestId_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPSRequestId)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPSRequestId +pub extern "C" fn LSPSRequestId_clone(orig: &LSPSRequestId) -> LSPSRequestId { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPSRequestId object +pub extern "C" fn LSPSRequestId_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps0::ser::LSPSRequestId }).into()} +/// Checks if two LSPSRequestIds contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPSRequestId_eq(a: &LSPSRequestId, b: &LSPSRequestId) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Generates a non-cryptographic 64-bit hash of the LSPSRequestId. +#[no_mangle] +pub extern "C" fn LSPSRequestId_hash(o: &LSPSRequestId) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} + +use lightning_liquidity::lsps0::ser::LSPSDateTime as nativeLSPSDateTimeImport; +pub(crate) type nativeLSPSDateTime = nativeLSPSDateTimeImport; + +/// An object representing datetimes as described in bLIP-50 / LSPS0. +#[must_use] +#[repr(C)] +pub struct LSPSDateTime { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPSDateTime, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPSDateTime { + type Target = nativeLSPSDateTime; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPSDateTime { } +unsafe impl core::marker::Sync for LSPSDateTime { } +impl Drop for LSPSDateTime { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPSDateTime>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPSDateTime, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPSDateTime_free(this_obj: LSPSDateTime) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPSDateTime_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPSDateTime) }; +} +#[allow(unused)] +impl LSPSDateTime { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPSDateTime { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPSDateTime { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPSDateTime { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for LSPSDateTime { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPSDateTime>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPSDateTime_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPSDateTime)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPSDateTime +pub extern "C" fn LSPSDateTime_clone(orig: &LSPSDateTime) -> LSPSDateTime { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPSDateTime object +pub extern "C" fn LSPSDateTime_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps0::ser::LSPSDateTime }).into()} +/// Checks if two LSPSDateTimes contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPSDateTime_eq(a: &LSPSDateTime, b: &LSPSDateTime) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Generates a non-cryptographic 64-bit hash of the LSPSDateTime. +#[no_mangle] +pub extern "C" fn LSPSDateTime_hash(o: &LSPSDateTime) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Returns the LSPSDateTime as RFC3339 formatted string. +#[must_use] +#[no_mangle] +pub extern "C" fn LSPSDateTime_to_rfc3339(this_arg: &crate::lightning_liquidity::lsps0::ser::LSPSDateTime) -> crate::c_types::Str { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.to_rfc3339(); + ret.into() +} + +/// Returns if the given time is in the past. +#[must_use] +#[no_mangle] +pub extern "C" fn LSPSDateTime_is_past(this_arg: &crate::lightning_liquidity::lsps0::ser::LSPSDateTime) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_past(); + ret +} + +#[no_mangle] +/// Read a LSPSDateTime object from a string +pub extern "C" fn LSPSDateTime_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_LSPSDateTimeNoneZ { + match lightning_liquidity::lsps0::ser::LSPSDateTime::from_str(s.into_str()) { + Ok(r) => { + crate::c_types::CResultTempl::ok( + crate::lightning_liquidity::lsps0::ser::LSPSDateTime { inner: ObjOps::heap_alloc(r), is_owned: true } + ) + }, + Err(e) => { + crate::c_types::CResultTempl::err( + () /*e*/ + ) + }, + }.into() +} +#[no_mangle] +/// Get the string representation of a LSPSDateTime object +pub extern "C" fn LSPSDateTime_to_str(o: &crate::lightning_liquidity::lsps0::ser::LSPSDateTime) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} + +use lightning_liquidity::lsps0::ser::LSPSResponseError as nativeLSPSResponseErrorImport; +pub(crate) type nativeLSPSResponseError = nativeLSPSResponseErrorImport; + +/// An error returned in response to an JSON-RPC request. +/// +/// Please refer to the [JSON-RPC 2.0 specification](https://www.jsonrpc.org/specification#error_object) for +/// more information. +#[must_use] +#[repr(C)] +pub struct LSPSResponseError { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPSResponseError, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPSResponseError { + type Target = nativeLSPSResponseError; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPSResponseError { } +unsafe impl core::marker::Sync for LSPSResponseError { } +impl Drop for LSPSResponseError { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPSResponseError>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPSResponseError, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPSResponseError_free(this_obj: LSPSResponseError) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPSResponseError_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPSResponseError) }; +} +#[allow(unused)] +impl LSPSResponseError { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPSResponseError { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPSResponseError { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPSResponseError { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// A string providing a short description of the error. +#[no_mangle] +pub extern "C" fn LSPSResponseError_get_message(this_ptr: &LSPSResponseError) -> crate::c_types::Str { + let mut inner_val = &mut this_ptr.get_native_mut_ref().message; + inner_val.as_str().into() +} +/// A string providing a short description of the error. +#[no_mangle] +pub extern "C" fn LSPSResponseError_set_message(this_ptr: &mut LSPSResponseError, mut val: crate::c_types::Str) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.message = val.into_string(); +} +/// A primitive or structured value that contains additional information about the error. +#[no_mangle] +pub extern "C" fn LSPSResponseError_get_data(this_ptr: &LSPSResponseError) -> crate::c_types::derived::COption_StrZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().data; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_StrZ::None } else { crate::c_types::derived::COption_StrZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into() }) }; + local_inner_val +} +/// A primitive or structured value that contains additional information about the error. +#[no_mangle] +pub extern "C" fn LSPSResponseError_set_data(this_ptr: &mut LSPSResponseError, mut val: crate::c_types::derived::COption_StrZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_string() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val; +} +impl Clone for LSPSResponseError { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPSResponseError>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPSResponseError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPSResponseError)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPSResponseError +pub extern "C" fn LSPSResponseError_clone(orig: &LSPSResponseError) -> LSPSResponseError { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPSResponseError object +pub extern "C" fn LSPSResponseError_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps0::ser::LSPSResponseError }).into()} +/// Checks if two LSPSResponseErrors contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPSResponseError_eq(a: &LSPSResponseError, b: &LSPSResponseError) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// A (de-)serializable LSPS message allowing to be sent over the wire. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPSMessage { + /// An invalid variant. + Invalid( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError), + /// An LSPS0 message. + LSPS0( + crate::lightning_liquidity::lsps0::msgs::LSPS0Message), + /// An LSPS1 message. + LSPS1( + crate::lightning_liquidity::lsps1::msgs::LSPS1Message), + /// An LSPS2 message. + LSPS2( + crate::lightning_liquidity::lsps2::msgs::LSPS2Message), +} +use lightning_liquidity::lsps0::ser::LSPSMessage as LSPSMessageImport; +pub(crate) type nativeLSPSMessage = LSPSMessageImport; + +impl LSPSMessage { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPSMessage { + match self { + LSPSMessage::Invalid (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPSMessage::Invalid ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPSMessage::LSPS0 (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPSMessage::LSPS0 ( + a_nonref.into_native(), + ) + }, + LSPSMessage::LSPS1 (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPSMessage::LSPS1 ( + a_nonref.into_native(), + ) + }, + LSPSMessage::LSPS2 (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPSMessage::LSPS2 ( + a_nonref.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPSMessage { + match self { + LSPSMessage::Invalid (mut a, ) => { + nativeLSPSMessage::Invalid ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPSMessage::LSPS0 (mut a, ) => { + nativeLSPSMessage::LSPS0 ( + a.into_native(), + ) + }, + LSPSMessage::LSPS1 (mut a, ) => { + nativeLSPSMessage::LSPS1 ( + a.into_native(), + ) + }, + LSPSMessage::LSPS2 (mut a, ) => { + nativeLSPSMessage::LSPS2 ( + a.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPSMessageImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPSMessage) }; + match native { + nativeLSPSMessage::Invalid (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPSMessage::Invalid ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPSMessage::LSPS0 (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPSMessage::LSPS0 ( + crate::lightning_liquidity::lsps0::msgs::LSPS0Message::native_into(a_nonref), + ) + }, + nativeLSPSMessage::LSPS1 (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPSMessage::LSPS1 ( + crate::lightning_liquidity::lsps1::msgs::LSPS1Message::native_into(a_nonref), + ) + }, + nativeLSPSMessage::LSPS2 (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPSMessage::LSPS2 ( + crate::lightning_liquidity::lsps2::msgs::LSPS2Message::native_into(a_nonref), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPSMessage) -> Self { + match native { + nativeLSPSMessage::Invalid (mut a, ) => { + LSPSMessage::Invalid ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPSMessage::LSPS0 (mut a, ) => { + LSPSMessage::LSPS0 ( + crate::lightning_liquidity::lsps0::msgs::LSPS0Message::native_into(a), + ) + }, + nativeLSPSMessage::LSPS1 (mut a, ) => { + LSPSMessage::LSPS1 ( + crate::lightning_liquidity::lsps1::msgs::LSPS1Message::native_into(a), + ) + }, + nativeLSPSMessage::LSPS2 (mut a, ) => { + LSPSMessage::LSPS2 ( + crate::lightning_liquidity::lsps2::msgs::LSPS2Message::native_into(a), + ) + }, + } + } +} +/// Frees any resources used by the LSPSMessage +#[no_mangle] +pub extern "C" fn LSPSMessage_free(this_ptr: LSPSMessage) { } +/// Creates a copy of the LSPSMessage +#[no_mangle] +pub extern "C" fn LSPSMessage_clone(orig: &LSPSMessage) -> LSPSMessage { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPSMessage_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPSMessage)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPSMessage_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPSMessage) }; +} +#[no_mangle] +/// Utility method to constructs a new Invalid-variant LSPSMessage +pub extern "C" fn LSPSMessage_invalid(a: crate::lightning_liquidity::lsps0::ser::LSPSResponseError) -> LSPSMessage { + LSPSMessage::Invalid(a, ) +} +#[no_mangle] +/// Utility method to constructs a new LSPS0-variant LSPSMessage +pub extern "C" fn LSPSMessage_lsps0(a: crate::lightning_liquidity::lsps0::msgs::LSPS0Message) -> LSPSMessage { + LSPSMessage::LSPS0(a, ) +} +#[no_mangle] +/// Utility method to constructs a new LSPS1-variant LSPSMessage +pub extern "C" fn LSPSMessage_lsps1(a: crate::lightning_liquidity::lsps1::msgs::LSPS1Message) -> LSPSMessage { + LSPSMessage::LSPS1(a, ) +} +#[no_mangle] +/// Utility method to constructs a new LSPS2-variant LSPSMessage +pub extern "C" fn LSPSMessage_lsps2(a: crate::lightning_liquidity::lsps2::msgs::LSPS2Message) -> LSPSMessage { + LSPSMessage::LSPS2(a, ) +} +/// Get a string which allows debug introspection of a LSPSMessage object +pub extern "C" fn LSPSMessage_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps0::ser::LSPSMessage }).into()} +/// Checks if two LSPSMessages contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPSMessage_eq(a: &LSPSMessage, b: &LSPSMessage) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +mod string_amount { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} +mod string_amount_option { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} +mod unchecked_address { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} +mod unchecked_address_option { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} +mod u32_fee_rate { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps0/service.rs b/lightning-c-bindings/src/lightning_liquidity/lsps0/service.rs new file mode 100644 index 00000000..3d734ba6 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps0/service.rs @@ -0,0 +1,83 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Contains the main bLIP-50 / LSPS0 server-side object, [`LSPS0ServiceHandler`]. +//! +//! Please refer to the [bLIP-50 / LSPS0 +//! specifcation](https://github.com/lightning/blips/blob/master/blip-0050.md) for more +//! information. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning_liquidity::lsps0::service::LSPS0ServiceHandler as nativeLSPS0ServiceHandlerImport; +pub(crate) type nativeLSPS0ServiceHandler = nativeLSPS0ServiceHandlerImport; + +/// The main server-side object allowing to send and receive bLIP-50 / LSPS0 messages. +#[must_use] +#[repr(C)] +pub struct LSPS0ServiceHandler { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS0ServiceHandler, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS0ServiceHandler { + type Target = nativeLSPS0ServiceHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS0ServiceHandler { } +unsafe impl core::marker::Sync for LSPS0ServiceHandler { } +impl Drop for LSPS0ServiceHandler { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS0ServiceHandler>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS0ServiceHandler, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS0ServiceHandler_free(this_obj: LSPS0ServiceHandler) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS0ServiceHandler_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS0ServiceHandler) }; +} +#[allow(unused)] +impl LSPS0ServiceHandler { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS0ServiceHandler { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS0ServiceHandler { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS0ServiceHandler { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps1/client.rs b/lightning-c-bindings/src/lightning_liquidity/lsps1/client.rs new file mode 100644 index 00000000..113f3af4 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps1/client.rs @@ -0,0 +1,222 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Contains the main bLIP-51 / LSPS1 client object, [`LSPS1ClientHandler`]. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning_liquidity::lsps1::client::LSPS1ClientConfig as nativeLSPS1ClientConfigImport; +pub(crate) type nativeLSPS1ClientConfig = nativeLSPS1ClientConfigImport; + +/// Client-side configuration options for bLIP-51 / LSPS1 channel requests. +#[must_use] +#[repr(C)] +pub struct LSPS1ClientConfig { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1ClientConfig, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1ClientConfig { + type Target = nativeLSPS1ClientConfig; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1ClientConfig { } +unsafe impl core::marker::Sync for LSPS1ClientConfig { } +impl Drop for LSPS1ClientConfig { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1ClientConfig>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1ClientConfig, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1ClientConfig_free(this_obj: LSPS1ClientConfig) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1ClientConfig_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1ClientConfig) }; +} +#[allow(unused)] +impl LSPS1ClientConfig { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1ClientConfig { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1ClientConfig { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1ClientConfig { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The maximally allowed channel fees. +#[no_mangle] +pub extern "C" fn LSPS1ClientConfig_get_max_channel_fees_msat(this_ptr: &LSPS1ClientConfig) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_channel_fees_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The maximally allowed channel fees. +#[no_mangle] +pub extern "C" fn LSPS1ClientConfig_set_max_channel_fees_msat(this_ptr: &mut LSPS1ClientConfig, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_channel_fees_msat = local_val; +} +/// Constructs a new LSPS1ClientConfig given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1ClientConfig_new(mut max_channel_fees_msat_arg: crate::c_types::derived::COption_u64Z) -> LSPS1ClientConfig { + let mut local_max_channel_fees_msat_arg = if max_channel_fees_msat_arg.is_some() { Some( { max_channel_fees_msat_arg.take() }) } else { None }; + LSPS1ClientConfig { inner: ObjOps::heap_alloc(nativeLSPS1ClientConfig { + max_channel_fees_msat: local_max_channel_fees_msat_arg, + }), is_owned: true } +} +impl Clone for LSPS1ClientConfig { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1ClientConfig>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1ClientConfig_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1ClientConfig)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1ClientConfig +pub extern "C" fn LSPS1ClientConfig_clone(orig: &LSPS1ClientConfig) -> LSPS1ClientConfig { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1ClientConfig object +pub extern "C" fn LSPS1ClientConfig_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::client::LSPS1ClientConfig }).into()} + +use lightning_liquidity::lsps1::client::LSPS1ClientHandler as nativeLSPS1ClientHandlerImport; +pub(crate) type nativeLSPS1ClientHandler = nativeLSPS1ClientHandlerImport; + +/// The main object allowing to send and receive bLIP-51 / LSPS1 messages. +#[must_use] +#[repr(C)] +pub struct LSPS1ClientHandler { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1ClientHandler, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1ClientHandler { + type Target = nativeLSPS1ClientHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1ClientHandler { } +unsafe impl core::marker::Sync for LSPS1ClientHandler { } +impl Drop for LSPS1ClientHandler { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1ClientHandler>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1ClientHandler, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1ClientHandler_free(this_obj: LSPS1ClientHandler) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1ClientHandler_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1ClientHandler) }; +} +#[allow(unused)] +impl LSPS1ClientHandler { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1ClientHandler { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1ClientHandler { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1ClientHandler { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Request the supported options from the LSP. +/// +/// The user will receive the LSP's response via an [`SupportedOptionsReady`] event. +/// +/// `counterparty_node_id` is the `node_id` of the LSP you would like to use. +/// +/// Returns the used [`LSPSRequestId`], which will be returned via [`SupportedOptionsReady`]. +/// +/// [`SupportedOptionsReady`]: crate::lsps1::event::LSPS1ClientEvent::SupportedOptionsReady +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1ClientHandler_request_supported_options(this_arg: &crate::lightning_liquidity::lsps1::client::LSPS1ClientHandler, mut counterparty_node_id: crate::c_types::PublicKey) -> crate::lightning_liquidity::lsps0::ser::LSPSRequestId { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.request_supported_options(counterparty_node_id.into_rust()); + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Places an order with the connected LSP given its `counterparty_node_id`. +/// +/// The client agrees to paying channel fees according to the provided parameters. +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1ClientHandler_create_order(this_arg: &crate::lightning_liquidity::lsps1::client::LSPS1ClientHandler, mut counterparty_node_id: crate::c_types::PublicKey, mut order: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams, mut refund_onchain_address: crate::c_types::derived::COption_AddressZ) -> crate::lightning_liquidity::lsps0::ser::LSPSRequestId { + let mut local_refund_onchain_address = { /*refund_onchain_address*/ let refund_onchain_address_opt = refund_onchain_address; if refund_onchain_address_opt.is_none() { None } else { Some({ { { refund_onchain_address_opt.take() }.into_rust() }})} }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_order(&counterparty_node_id.into_rust(), *unsafe { Box::from_raw(order.take_inner()) }, local_refund_onchain_address); + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Queries the status of a pending payment, i.e., whether a payment has been received by the LSP. +/// +/// Upon success an [`LSPS1ClientEvent::OrderStatus`] event will be emitted. +/// +/// [`LSPS1ClientEvent::OrderStatus`]: crate::lsps1::event::LSPS1ClientEvent::OrderStatus +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1ClientHandler_check_order_status(this_arg: &crate::lightning_liquidity::lsps1::client::LSPS1ClientHandler, mut counterparty_node_id: crate::c_types::PublicKey, mut order_id: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId) -> crate::lightning_liquidity::lsps0::ser::LSPSRequestId { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.check_order_status(&counterparty_node_id.into_rust(), *unsafe { Box::from_raw(order_id.take_inner()) }); + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps1/event.rs b/lightning-c-bindings/src/lightning_liquidity/lsps1/event.rs new file mode 100644 index 00000000..f3a7fe7e --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps1/event.rs @@ -0,0 +1,457 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Contains bLIP-51 / LSPS1 event types + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// An event which an bLIP-51 / LSPS1 client should take some action in response to. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS1ClientEvent { + /// A request previously issued via [`LSPS1ClientHandler::request_supported_options`] + /// succeeded as the LSP returned the options it supports. + /// + /// You must check whether LSP supports the parameters the client wants and then call + /// [`LSPS1ClientHandler::create_order`] to place an order. + /// + /// [`LSPS1ClientHandler::request_supported_options`]: crate::lsps1::client::LSPS1ClientHandler::request_supported_options + /// [`LSPS1ClientHandler::create_order`]: crate::lsps1::client::LSPS1ClientHandler::create_order + SupportedOptionsReady { + /// The identifier of the issued bLIP-51 / LSPS1 `get_info` request, as returned by + /// [`LSPS1ClientHandler::request_supported_options`] + /// + /// This can be used to track which request this event corresponds to. + /// + /// [`LSPS1ClientHandler::request_supported_options`]: crate::lsps1::client::LSPS1ClientHandler::request_supported_options + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + /// The node id of the LSP that provided this response. + counterparty_node_id: crate::c_types::PublicKey, + /// All options supported by the LSP. + supported_options: crate::lightning_liquidity::lsps1::msgs::LSPS1Options, + }, + /// A request previously issued via [`LSPS1ClientHandler::request_supported_options`] + /// failed as the LSP returned an error response. + /// + /// [`LSPS1ClientHandler::request_supported_options`]: crate::lsps1::client::LSPS1ClientHandler::request_supported_options + SupportedOptionsRequestFailed { + /// The identifier of the issued bLIP-51 / LSPS1 `get_info` request, as returned by + /// [`LSPS1ClientHandler::request_supported_options`] + /// + /// This can be used to track which request this event corresponds to. + /// + /// [`LSPS1ClientHandler::request_supported_options`]: crate::lsps1::client::LSPS1ClientHandler::request_supported_options + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + /// The node id of the LSP that provided this response. + counterparty_node_id: crate::c_types::PublicKey, + /// The error that was returned. + error: crate::lightning_liquidity::lsps0::ser::LSPSResponseError, + }, + /// Confirmation from the LSP about the order created by the client. + /// + /// When the payment is confirmed, the LSP will open a channel to you + /// with the below agreed upon parameters. + /// + /// You must pay the invoice or onchain address if you want to continue and then + /// call [`LSPS1ClientHandler::check_order_status`] with the order id + /// to get information from LSP about progress of the order. + /// + /// [`LSPS1ClientHandler::check_order_status`]: crate::lsps1::client::LSPS1ClientHandler::check_order_status + OrderCreated { + /// The identifier of the issued bLIP-51 / LSPS1 `create_order` request, as returned by + /// [`LSPS1ClientHandler::create_order`] + /// + /// This can be used to track which request this event corresponds to. + /// + /// [`LSPS1ClientHandler::create_order`]: crate::lsps1::client::LSPS1ClientHandler::create_order + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + /// The node id of the LSP. + counterparty_node_id: crate::c_types::PublicKey, + /// The id of the channel order. + order_id: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId, + /// The order created by client and approved by LSP. + order: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams, + /// The details regarding payment of the order + payment: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo, + /// The details regarding state of the channel ordered. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + channel: crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo, + }, + /// Information from the LSP about the status of a previously created order. + /// + /// Will be emitted in response to calling [`LSPS1ClientHandler::check_order_status`]. + /// + /// [`LSPS1ClientHandler::check_order_status`]: crate::lsps1::client::LSPS1ClientHandler::check_order_status + OrderStatus { + /// The identifier of the issued bLIP-51 / LSPS1 `get_order` request, as returned by + /// [`LSPS1ClientHandler::check_order_status`] + /// + /// This can be used to track which request this event corresponds to. + /// + /// [`LSPS1ClientHandler::check_order_status`]: crate::lsps1::client::LSPS1ClientHandler::check_order_status + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + /// The node id of the LSP. + counterparty_node_id: crate::c_types::PublicKey, + /// The id of the channel order. + order_id: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId, + /// The order created by client and approved by LSP. + order: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams, + /// The details regarding payment of the order + payment: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo, + /// The details regarding state of the channel ordered. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + channel: crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo, + }, + /// A request previously issued via [`LSPS1ClientHandler::create_order`] or [`LSPS1ClientHandler::check_order_status`]. + /// failed as the LSP returned an error response. + /// + /// [`LSPS1ClientHandler::create_order`]: crate::lsps1::client::LSPS1ClientHandler::create_order + /// [`LSPS1ClientHandler::check_order_status`]: crate::lsps1::client::LSPS1ClientHandler::check_order_status + OrderRequestFailed { + /// The identifier of the issued LSPS1 `create_order` or `get_order` request, as returned by + /// [`LSPS1ClientHandler::create_order`] or [`LSPS1ClientHandler::check_order_status`]. + /// + /// This can be used to track which request this event corresponds to. + /// + /// [`LSPS1ClientHandler::create_order`]: crate::lsps1::client::LSPS1ClientHandler::create_order + /// [`LSPS1ClientHandler::check_order_status`]: crate::lsps1::client::LSPS1ClientHandler::check_order_status + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + /// The node id of the LSP. + counterparty_node_id: crate::c_types::PublicKey, + /// The error that was returned. + error: crate::lightning_liquidity::lsps0::ser::LSPSResponseError, + }, +} +use lightning_liquidity::lsps1::event::LSPS1ClientEvent as LSPS1ClientEventImport; +pub(crate) type nativeLSPS1ClientEvent = LSPS1ClientEventImport; + +impl LSPS1ClientEvent { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS1ClientEvent { + match self { + LSPS1ClientEvent::SupportedOptionsReady {ref request_id, ref counterparty_node_id, ref supported_options, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut supported_options_nonref = Clone::clone(supported_options); + nativeLSPS1ClientEvent::SupportedOptionsReady { + request_id: *unsafe { Box::from_raw(request_id_nonref.take_inner()) }, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + supported_options: *unsafe { Box::from_raw(supported_options_nonref.take_inner()) }, + } + }, + LSPS1ClientEvent::SupportedOptionsRequestFailed {ref request_id, ref counterparty_node_id, ref error, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut error_nonref = Clone::clone(error); + nativeLSPS1ClientEvent::SupportedOptionsRequestFailed { + request_id: *unsafe { Box::from_raw(request_id_nonref.take_inner()) }, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + error: *unsafe { Box::from_raw(error_nonref.take_inner()) }, + } + }, + LSPS1ClientEvent::OrderCreated {ref request_id, ref counterparty_node_id, ref order_id, ref order, ref payment, ref channel, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut order_id_nonref = Clone::clone(order_id); + let mut order_nonref = Clone::clone(order); + let mut payment_nonref = Clone::clone(payment); + let mut channel_nonref = Clone::clone(channel); + let mut local_channel_nonref = if channel_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_nonref.take_inner()) } }) }; + nativeLSPS1ClientEvent::OrderCreated { + request_id: *unsafe { Box::from_raw(request_id_nonref.take_inner()) }, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + order_id: *unsafe { Box::from_raw(order_id_nonref.take_inner()) }, + order: *unsafe { Box::from_raw(order_nonref.take_inner()) }, + payment: *unsafe { Box::from_raw(payment_nonref.take_inner()) }, + channel: local_channel_nonref, + } + }, + LSPS1ClientEvent::OrderStatus {ref request_id, ref counterparty_node_id, ref order_id, ref order, ref payment, ref channel, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut order_id_nonref = Clone::clone(order_id); + let mut order_nonref = Clone::clone(order); + let mut payment_nonref = Clone::clone(payment); + let mut channel_nonref = Clone::clone(channel); + let mut local_channel_nonref = if channel_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_nonref.take_inner()) } }) }; + nativeLSPS1ClientEvent::OrderStatus { + request_id: *unsafe { Box::from_raw(request_id_nonref.take_inner()) }, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + order_id: *unsafe { Box::from_raw(order_id_nonref.take_inner()) }, + order: *unsafe { Box::from_raw(order_nonref.take_inner()) }, + payment: *unsafe { Box::from_raw(payment_nonref.take_inner()) }, + channel: local_channel_nonref, + } + }, + LSPS1ClientEvent::OrderRequestFailed {ref request_id, ref counterparty_node_id, ref error, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut error_nonref = Clone::clone(error); + nativeLSPS1ClientEvent::OrderRequestFailed { + request_id: *unsafe { Box::from_raw(request_id_nonref.take_inner()) }, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + error: *unsafe { Box::from_raw(error_nonref.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS1ClientEvent { + match self { + LSPS1ClientEvent::SupportedOptionsReady {mut request_id, mut counterparty_node_id, mut supported_options, } => { + nativeLSPS1ClientEvent::SupportedOptionsReady { + request_id: *unsafe { Box::from_raw(request_id.take_inner()) }, + counterparty_node_id: counterparty_node_id.into_rust(), + supported_options: *unsafe { Box::from_raw(supported_options.take_inner()) }, + } + }, + LSPS1ClientEvent::SupportedOptionsRequestFailed {mut request_id, mut counterparty_node_id, mut error, } => { + nativeLSPS1ClientEvent::SupportedOptionsRequestFailed { + request_id: *unsafe { Box::from_raw(request_id.take_inner()) }, + counterparty_node_id: counterparty_node_id.into_rust(), + error: *unsafe { Box::from_raw(error.take_inner()) }, + } + }, + LSPS1ClientEvent::OrderCreated {mut request_id, mut counterparty_node_id, mut order_id, mut order, mut payment, mut channel, } => { + let mut local_channel = if channel.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel.take_inner()) } }) }; + nativeLSPS1ClientEvent::OrderCreated { + request_id: *unsafe { Box::from_raw(request_id.take_inner()) }, + counterparty_node_id: counterparty_node_id.into_rust(), + order_id: *unsafe { Box::from_raw(order_id.take_inner()) }, + order: *unsafe { Box::from_raw(order.take_inner()) }, + payment: *unsafe { Box::from_raw(payment.take_inner()) }, + channel: local_channel, + } + }, + LSPS1ClientEvent::OrderStatus {mut request_id, mut counterparty_node_id, mut order_id, mut order, mut payment, mut channel, } => { + let mut local_channel = if channel.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel.take_inner()) } }) }; + nativeLSPS1ClientEvent::OrderStatus { + request_id: *unsafe { Box::from_raw(request_id.take_inner()) }, + counterparty_node_id: counterparty_node_id.into_rust(), + order_id: *unsafe { Box::from_raw(order_id.take_inner()) }, + order: *unsafe { Box::from_raw(order.take_inner()) }, + payment: *unsafe { Box::from_raw(payment.take_inner()) }, + channel: local_channel, + } + }, + LSPS1ClientEvent::OrderRequestFailed {mut request_id, mut counterparty_node_id, mut error, } => { + nativeLSPS1ClientEvent::OrderRequestFailed { + request_id: *unsafe { Box::from_raw(request_id.take_inner()) }, + counterparty_node_id: counterparty_node_id.into_rust(), + error: *unsafe { Box::from_raw(error.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS1ClientEventImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS1ClientEvent) }; + match native { + nativeLSPS1ClientEvent::SupportedOptionsReady {ref request_id, ref counterparty_node_id, ref supported_options, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut supported_options_nonref = Clone::clone(supported_options); + LSPS1ClientEvent::SupportedOptionsReady { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id_nonref), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + supported_options: crate::lightning_liquidity::lsps1::msgs::LSPS1Options { inner: ObjOps::heap_alloc(supported_options_nonref), is_owned: true }, + } + }, + nativeLSPS1ClientEvent::SupportedOptionsRequestFailed {ref request_id, ref counterparty_node_id, ref error, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut error_nonref = Clone::clone(error); + LSPS1ClientEvent::SupportedOptionsRequestFailed { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id_nonref), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + error: crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(error_nonref), is_owned: true }, + } + }, + nativeLSPS1ClientEvent::OrderCreated {ref request_id, ref counterparty_node_id, ref order_id, ref order, ref payment, ref channel, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut order_id_nonref = Clone::clone(order_id); + let mut order_nonref = Clone::clone(order); + let mut payment_nonref = Clone::clone(payment); + let mut channel_nonref = Clone::clone(channel); + let mut local_channel_nonref = crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo { inner: if channel_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_nonref.unwrap())) } }, is_owned: true }; + LSPS1ClientEvent::OrderCreated { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id_nonref), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + order_id: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId { inner: ObjOps::heap_alloc(order_id_nonref), is_owned: true }, + order: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams { inner: ObjOps::heap_alloc(order_nonref), is_owned: true }, + payment: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo { inner: ObjOps::heap_alloc(payment_nonref), is_owned: true }, + channel: local_channel_nonref, + } + }, + nativeLSPS1ClientEvent::OrderStatus {ref request_id, ref counterparty_node_id, ref order_id, ref order, ref payment, ref channel, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut order_id_nonref = Clone::clone(order_id); + let mut order_nonref = Clone::clone(order); + let mut payment_nonref = Clone::clone(payment); + let mut channel_nonref = Clone::clone(channel); + let mut local_channel_nonref = crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo { inner: if channel_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_nonref.unwrap())) } }, is_owned: true }; + LSPS1ClientEvent::OrderStatus { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id_nonref), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + order_id: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId { inner: ObjOps::heap_alloc(order_id_nonref), is_owned: true }, + order: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams { inner: ObjOps::heap_alloc(order_nonref), is_owned: true }, + payment: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo { inner: ObjOps::heap_alloc(payment_nonref), is_owned: true }, + channel: local_channel_nonref, + } + }, + nativeLSPS1ClientEvent::OrderRequestFailed {ref request_id, ref counterparty_node_id, ref error, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut error_nonref = Clone::clone(error); + LSPS1ClientEvent::OrderRequestFailed { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id_nonref), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + error: crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(error_nonref), is_owned: true }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS1ClientEvent) -> Self { + match native { + nativeLSPS1ClientEvent::SupportedOptionsReady {mut request_id, mut counterparty_node_id, mut supported_options, } => { + LSPS1ClientEvent::SupportedOptionsReady { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + supported_options: crate::lightning_liquidity::lsps1::msgs::LSPS1Options { inner: ObjOps::heap_alloc(supported_options), is_owned: true }, + } + }, + nativeLSPS1ClientEvent::SupportedOptionsRequestFailed {mut request_id, mut counterparty_node_id, mut error, } => { + LSPS1ClientEvent::SupportedOptionsRequestFailed { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + error: crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(error), is_owned: true }, + } + }, + nativeLSPS1ClientEvent::OrderCreated {mut request_id, mut counterparty_node_id, mut order_id, mut order, mut payment, mut channel, } => { + let mut local_channel = crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo { inner: if channel.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel.unwrap())) } }, is_owned: true }; + LSPS1ClientEvent::OrderCreated { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + order_id: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId { inner: ObjOps::heap_alloc(order_id), is_owned: true }, + order: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams { inner: ObjOps::heap_alloc(order), is_owned: true }, + payment: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo { inner: ObjOps::heap_alloc(payment), is_owned: true }, + channel: local_channel, + } + }, + nativeLSPS1ClientEvent::OrderStatus {mut request_id, mut counterparty_node_id, mut order_id, mut order, mut payment, mut channel, } => { + let mut local_channel = crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo { inner: if channel.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel.unwrap())) } }, is_owned: true }; + LSPS1ClientEvent::OrderStatus { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + order_id: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId { inner: ObjOps::heap_alloc(order_id), is_owned: true }, + order: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams { inner: ObjOps::heap_alloc(order), is_owned: true }, + payment: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo { inner: ObjOps::heap_alloc(payment), is_owned: true }, + channel: local_channel, + } + }, + nativeLSPS1ClientEvent::OrderRequestFailed {mut request_id, mut counterparty_node_id, mut error, } => { + LSPS1ClientEvent::OrderRequestFailed { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + error: crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(error), is_owned: true }, + } + }, + } + } +} +/// Frees any resources used by the LSPS1ClientEvent +#[no_mangle] +pub extern "C" fn LSPS1ClientEvent_free(this_ptr: LSPS1ClientEvent) { } +/// Creates a copy of the LSPS1ClientEvent +#[no_mangle] +pub extern "C" fn LSPS1ClientEvent_clone(orig: &LSPS1ClientEvent) -> LSPS1ClientEvent { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1ClientEvent_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS1ClientEvent)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1ClientEvent_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS1ClientEvent) }; +} +#[no_mangle] +/// Utility method to constructs a new SupportedOptionsReady-variant LSPS1ClientEvent +pub extern "C" fn LSPS1ClientEvent_supported_options_ready(request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, counterparty_node_id: crate::c_types::PublicKey, supported_options: crate::lightning_liquidity::lsps1::msgs::LSPS1Options) -> LSPS1ClientEvent { + LSPS1ClientEvent::SupportedOptionsReady { + request_id, + counterparty_node_id, + supported_options, + } +} +#[no_mangle] +/// Utility method to constructs a new SupportedOptionsRequestFailed-variant LSPS1ClientEvent +pub extern "C" fn LSPS1ClientEvent_supported_options_request_failed(request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, counterparty_node_id: crate::c_types::PublicKey, error: crate::lightning_liquidity::lsps0::ser::LSPSResponseError) -> LSPS1ClientEvent { + LSPS1ClientEvent::SupportedOptionsRequestFailed { + request_id, + counterparty_node_id, + error, + } +} +#[no_mangle] +/// Utility method to constructs a new OrderCreated-variant LSPS1ClientEvent +pub extern "C" fn LSPS1ClientEvent_order_created(request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, counterparty_node_id: crate::c_types::PublicKey, order_id: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId, order: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams, payment: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo, channel: crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo) -> LSPS1ClientEvent { + LSPS1ClientEvent::OrderCreated { + request_id, + counterparty_node_id, + order_id, + order, + payment, + channel, + } +} +#[no_mangle] +/// Utility method to constructs a new OrderStatus-variant LSPS1ClientEvent +pub extern "C" fn LSPS1ClientEvent_order_status(request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, counterparty_node_id: crate::c_types::PublicKey, order_id: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId, order: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams, payment: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo, channel: crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo) -> LSPS1ClientEvent { + LSPS1ClientEvent::OrderStatus { + request_id, + counterparty_node_id, + order_id, + order, + payment, + channel, + } +} +#[no_mangle] +/// Utility method to constructs a new OrderRequestFailed-variant LSPS1ClientEvent +pub extern "C" fn LSPS1ClientEvent_order_request_failed(request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, counterparty_node_id: crate::c_types::PublicKey, error: crate::lightning_liquidity::lsps0::ser::LSPSResponseError) -> LSPS1ClientEvent { + LSPS1ClientEvent::OrderRequestFailed { + request_id, + counterparty_node_id, + error, + } +} +/// Get a string which allows debug introspection of a LSPS1ClientEvent object +pub extern "C" fn LSPS1ClientEvent_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::event::LSPS1ClientEvent }).into()} +/// Checks if two LSPS1ClientEvents contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS1ClientEvent_eq(a: &LSPS1ClientEvent, b: &LSPS1ClientEvent) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps1/mod.rs b/lightning-c-bindings/src/lightning_liquidity/lsps1/mod.rs new file mode 100644 index 00000000..959b6bd7 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps1/mod.rs @@ -0,0 +1,22 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Types and primitives that implement the bLIP-51 / LSPS1: Channel Request specification. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +pub mod client; +pub mod event; +pub mod msgs; diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps1/msgs.rs b/lightning-c-bindings/src/lightning_liquidity/lsps1/msgs.rs new file mode 100644 index 00000000..35c97c26 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps1/msgs.rs @@ -0,0 +1,2617 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Message, request, and other primitive types used to implement bLIP-51 / LSPS1. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning_liquidity::lsps1::msgs::LSPS1OrderId as nativeLSPS1OrderIdImport; +pub(crate) type nativeLSPS1OrderId = nativeLSPS1OrderIdImport; + +/// The identifier of an order. +#[must_use] +#[repr(C)] +pub struct LSPS1OrderId { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1OrderId, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1OrderId { + type Target = nativeLSPS1OrderId; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1OrderId { } +unsafe impl core::marker::Sync for LSPS1OrderId { } +impl Drop for LSPS1OrderId { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1OrderId>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1OrderId, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1OrderId_free(this_obj: LSPS1OrderId) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1OrderId_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1OrderId) }; +} +#[allow(unused)] +impl LSPS1OrderId { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1OrderId { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1OrderId { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1OrderId { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn LSPS1OrderId_get_a(this_ptr: &LSPS1OrderId) -> crate::c_types::Str { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + inner_val.as_str().into() +} +#[no_mangle] +pub extern "C" fn LSPS1OrderId_set_a(this_ptr: &mut LSPS1OrderId, mut val: crate::c_types::Str) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_string(); +} +/// Constructs a new LSPS1OrderId given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1OrderId_new(mut a_arg: crate::c_types::Str) -> LSPS1OrderId { + LSPS1OrderId { inner: ObjOps::heap_alloc(lightning_liquidity::lsps1::msgs::LSPS1OrderId ( + a_arg.into_string(), + )), is_owned: true } +} +impl Clone for LSPS1OrderId { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1OrderId>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1OrderId_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1OrderId)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1OrderId +pub extern "C" fn LSPS1OrderId_clone(orig: &LSPS1OrderId) -> LSPS1OrderId { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1OrderId object +pub extern "C" fn LSPS1OrderId_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId }).into()} +/// Checks if two LSPS1OrderIds contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1OrderId_eq(a: &LSPS1OrderId, b: &LSPS1OrderId) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Generates a non-cryptographic 64-bit hash of the LSPS1OrderId. +#[no_mangle] +pub extern "C" fn LSPS1OrderId_hash(o: &LSPS1OrderId) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} + +use lightning_liquidity::lsps1::msgs::LSPS1GetInfoRequest as nativeLSPS1GetInfoRequestImport; +pub(crate) type nativeLSPS1GetInfoRequest = nativeLSPS1GetInfoRequestImport; + +/// A request made to an LSP to retrieve the supported options. +/// +/// Please refer to the [bLIP-51 / LSPS1 +/// specification](https://github.com/lightning/blips/blob/master/blip-0051.md#1-lsps1get_info) for +/// more information. +#[must_use] +#[repr(C)] +pub struct LSPS1GetInfoRequest { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1GetInfoRequest, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1GetInfoRequest { + type Target = nativeLSPS1GetInfoRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1GetInfoRequest { } +unsafe impl core::marker::Sync for LSPS1GetInfoRequest { } +impl Drop for LSPS1GetInfoRequest { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1GetInfoRequest>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1GetInfoRequest, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1GetInfoRequest_free(this_obj: LSPS1GetInfoRequest) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1GetInfoRequest_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1GetInfoRequest) }; +} +#[allow(unused)] +impl LSPS1GetInfoRequest { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1GetInfoRequest { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1GetInfoRequest { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1GetInfoRequest { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Constructs a new LSPS1GetInfoRequest given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1GetInfoRequest_new() -> LSPS1GetInfoRequest { + LSPS1GetInfoRequest { inner: ObjOps::heap_alloc(nativeLSPS1GetInfoRequest { + }), is_owned: true } +} +impl Clone for LSPS1GetInfoRequest { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1GetInfoRequest>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1GetInfoRequest_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1GetInfoRequest)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1GetInfoRequest +pub extern "C" fn LSPS1GetInfoRequest_clone(orig: &LSPS1GetInfoRequest) -> LSPS1GetInfoRequest { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1GetInfoRequest object +pub extern "C" fn LSPS1GetInfoRequest_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1GetInfoRequest }).into()} +/// Checks if two LSPS1GetInfoRequests contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1GetInfoRequest_eq(a: &LSPS1GetInfoRequest, b: &LSPS1GetInfoRequest) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps1::msgs::LSPS1Options as nativeLSPS1OptionsImport; +pub(crate) type nativeLSPS1Options = nativeLSPS1OptionsImport; + +/// An object representing the supported protocol options. +#[must_use] +#[repr(C)] +pub struct LSPS1Options { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1Options, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1Options { + type Target = nativeLSPS1Options; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1Options { } +unsafe impl core::marker::Sync for LSPS1Options { } +impl Drop for LSPS1Options { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1Options>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1Options, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1Options_free(this_obj: LSPS1Options) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1Options_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1Options) }; +} +#[allow(unused)] +impl LSPS1Options { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1Options { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1Options { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1Options { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The smallest number of confirmations needed for the LSP to accept a channel as confirmed. +#[no_mangle] +pub extern "C" fn LSPS1Options_get_min_required_channel_confirmations(this_ptr: &LSPS1Options) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_required_channel_confirmations; + *inner_val +} +/// The smallest number of confirmations needed for the LSP to accept a channel as confirmed. +#[no_mangle] +pub extern "C" fn LSPS1Options_set_min_required_channel_confirmations(this_ptr: &mut LSPS1Options, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_required_channel_confirmations = val; +} +/// The smallest number of blocks in which the LSP can confirm the funding transaction. +#[no_mangle] +pub extern "C" fn LSPS1Options_get_min_funding_confirms_within_blocks(this_ptr: &LSPS1Options) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_funding_confirms_within_blocks; + *inner_val +} +/// The smallest number of blocks in which the LSP can confirm the funding transaction. +#[no_mangle] +pub extern "C" fn LSPS1Options_set_min_funding_confirms_within_blocks(this_ptr: &mut LSPS1Options, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_funding_confirms_within_blocks = val; +} +/// Indicates if the LSP supports zero reserve. +#[no_mangle] +pub extern "C" fn LSPS1Options_get_supports_zero_channel_reserve(this_ptr: &LSPS1Options) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().supports_zero_channel_reserve; + *inner_val +} +/// Indicates if the LSP supports zero reserve. +#[no_mangle] +pub extern "C" fn LSPS1Options_set_supports_zero_channel_reserve(this_ptr: &mut LSPS1Options, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.supports_zero_channel_reserve = val; +} +/// The maximum number of blocks a channel can be leased for. +#[no_mangle] +pub extern "C" fn LSPS1Options_get_max_channel_expiry_blocks(this_ptr: &LSPS1Options) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_channel_expiry_blocks; + *inner_val +} +/// The maximum number of blocks a channel can be leased for. +#[no_mangle] +pub extern "C" fn LSPS1Options_set_max_channel_expiry_blocks(this_ptr: &mut LSPS1Options, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_channel_expiry_blocks = val; +} +/// The minimum number of satoshi that the client MUST request. +#[no_mangle] +pub extern "C" fn LSPS1Options_get_min_initial_client_balance_sat(this_ptr: &LSPS1Options) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_initial_client_balance_sat; + *inner_val +} +/// The minimum number of satoshi that the client MUST request. +#[no_mangle] +pub extern "C" fn LSPS1Options_set_min_initial_client_balance_sat(this_ptr: &mut LSPS1Options, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_initial_client_balance_sat = val; +} +/// The maximum number of satoshi that the client MUST request. +#[no_mangle] +pub extern "C" fn LSPS1Options_get_max_initial_client_balance_sat(this_ptr: &LSPS1Options) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_initial_client_balance_sat; + *inner_val +} +/// The maximum number of satoshi that the client MUST request. +#[no_mangle] +pub extern "C" fn LSPS1Options_set_max_initial_client_balance_sat(this_ptr: &mut LSPS1Options, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_initial_client_balance_sat = val; +} +/// The minimum number of satoshi that the LSP will provide to the channel. +#[no_mangle] +pub extern "C" fn LSPS1Options_get_min_initial_lsp_balance_sat(this_ptr: &LSPS1Options) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_initial_lsp_balance_sat; + *inner_val +} +/// The minimum number of satoshi that the LSP will provide to the channel. +#[no_mangle] +pub extern "C" fn LSPS1Options_set_min_initial_lsp_balance_sat(this_ptr: &mut LSPS1Options, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_initial_lsp_balance_sat = val; +} +/// The maximum number of satoshi that the LSP will provide to the channel. +#[no_mangle] +pub extern "C" fn LSPS1Options_get_max_initial_lsp_balance_sat(this_ptr: &LSPS1Options) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_initial_lsp_balance_sat; + *inner_val +} +/// The maximum number of satoshi that the LSP will provide to the channel. +#[no_mangle] +pub extern "C" fn LSPS1Options_set_max_initial_lsp_balance_sat(this_ptr: &mut LSPS1Options, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_initial_lsp_balance_sat = val; +} +/// The minimal channel size. +#[no_mangle] +pub extern "C" fn LSPS1Options_get_min_channel_balance_sat(this_ptr: &LSPS1Options) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_channel_balance_sat; + *inner_val +} +/// The minimal channel size. +#[no_mangle] +pub extern "C" fn LSPS1Options_set_min_channel_balance_sat(this_ptr: &mut LSPS1Options, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_channel_balance_sat = val; +} +/// The maximal channel size. +#[no_mangle] +pub extern "C" fn LSPS1Options_get_max_channel_balance_sat(this_ptr: &LSPS1Options) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_channel_balance_sat; + *inner_val +} +/// The maximal channel size. +#[no_mangle] +pub extern "C" fn LSPS1Options_set_max_channel_balance_sat(this_ptr: &mut LSPS1Options, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_channel_balance_sat = val; +} +/// Constructs a new LSPS1Options given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1Options_new(mut min_required_channel_confirmations_arg: u16, mut min_funding_confirms_within_blocks_arg: u16, mut supports_zero_channel_reserve_arg: bool, mut max_channel_expiry_blocks_arg: u32, mut min_initial_client_balance_sat_arg: u64, mut max_initial_client_balance_sat_arg: u64, mut min_initial_lsp_balance_sat_arg: u64, mut max_initial_lsp_balance_sat_arg: u64, mut min_channel_balance_sat_arg: u64, mut max_channel_balance_sat_arg: u64) -> LSPS1Options { + LSPS1Options { inner: ObjOps::heap_alloc(nativeLSPS1Options { + min_required_channel_confirmations: min_required_channel_confirmations_arg, + min_funding_confirms_within_blocks: min_funding_confirms_within_blocks_arg, + supports_zero_channel_reserve: supports_zero_channel_reserve_arg, + max_channel_expiry_blocks: max_channel_expiry_blocks_arg, + min_initial_client_balance_sat: min_initial_client_balance_sat_arg, + max_initial_client_balance_sat: max_initial_client_balance_sat_arg, + min_initial_lsp_balance_sat: min_initial_lsp_balance_sat_arg, + max_initial_lsp_balance_sat: max_initial_lsp_balance_sat_arg, + min_channel_balance_sat: min_channel_balance_sat_arg, + max_channel_balance_sat: max_channel_balance_sat_arg, + }), is_owned: true } +} +impl Clone for LSPS1Options { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1Options>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1Options_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1Options)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1Options +pub extern "C" fn LSPS1Options_clone(orig: &LSPS1Options) -> LSPS1Options { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1Options object +pub extern "C" fn LSPS1Options_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1Options }).into()} +/// Checks if two LSPS1Optionss contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1Options_eq(a: &LSPS1Options, b: &LSPS1Options) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps1::msgs::LSPS1GetInfoResponse as nativeLSPS1GetInfoResponseImport; +pub(crate) type nativeLSPS1GetInfoResponse = nativeLSPS1GetInfoResponseImport; + +/// A response to a [`LSPS1GetInfoRequest`]. +#[must_use] +#[repr(C)] +pub struct LSPS1GetInfoResponse { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1GetInfoResponse, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1GetInfoResponse { + type Target = nativeLSPS1GetInfoResponse; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1GetInfoResponse { } +unsafe impl core::marker::Sync for LSPS1GetInfoResponse { } +impl Drop for LSPS1GetInfoResponse { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1GetInfoResponse>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1GetInfoResponse, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1GetInfoResponse_free(this_obj: LSPS1GetInfoResponse) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1GetInfoResponse_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1GetInfoResponse) }; +} +#[allow(unused)] +impl LSPS1GetInfoResponse { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1GetInfoResponse { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1GetInfoResponse { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1GetInfoResponse { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// All options supported by the LSP. +#[no_mangle] +pub extern "C" fn LSPS1GetInfoResponse_get_options(this_ptr: &LSPS1GetInfoResponse) -> crate::lightning_liquidity::lsps1::msgs::LSPS1Options { + let mut inner_val = &mut this_ptr.get_native_mut_ref().options; + crate::lightning_liquidity::lsps1::msgs::LSPS1Options { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps1::msgs::LSPS1Options<>) as *mut _) }, is_owned: false } +} +/// All options supported by the LSP. +#[no_mangle] +pub extern "C" fn LSPS1GetInfoResponse_set_options(this_ptr: &mut LSPS1GetInfoResponse, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1Options) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.options = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new LSPS1GetInfoResponse given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1GetInfoResponse_new(mut options_arg: crate::lightning_liquidity::lsps1::msgs::LSPS1Options) -> LSPS1GetInfoResponse { + LSPS1GetInfoResponse { inner: ObjOps::heap_alloc(nativeLSPS1GetInfoResponse { + options: *unsafe { Box::from_raw(options_arg.take_inner()) }, + }), is_owned: true } +} +impl Clone for LSPS1GetInfoResponse { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1GetInfoResponse>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1GetInfoResponse_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1GetInfoResponse)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1GetInfoResponse +pub extern "C" fn LSPS1GetInfoResponse_clone(orig: &LSPS1GetInfoResponse) -> LSPS1GetInfoResponse { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1GetInfoResponse object +pub extern "C" fn LSPS1GetInfoResponse_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1GetInfoResponse }).into()} +/// Checks if two LSPS1GetInfoResponses contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1GetInfoResponse_eq(a: &LSPS1GetInfoResponse, b: &LSPS1GetInfoResponse) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps1::msgs::LSPS1CreateOrderRequest as nativeLSPS1CreateOrderRequestImport; +pub(crate) type nativeLSPS1CreateOrderRequest = nativeLSPS1CreateOrderRequestImport; + +/// A request made to an LSP to create an order. +/// +/// Please refer to the [bLIP-51 / LSPS1 +/// specification](https://github.com/lightning/blips/blob/master/blip-0051.md#2-lsps1create_order) +/// for more information. +#[must_use] +#[repr(C)] +pub struct LSPS1CreateOrderRequest { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1CreateOrderRequest, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1CreateOrderRequest { + type Target = nativeLSPS1CreateOrderRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1CreateOrderRequest { } +unsafe impl core::marker::Sync for LSPS1CreateOrderRequest { } +impl Drop for LSPS1CreateOrderRequest { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1CreateOrderRequest>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1CreateOrderRequest, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderRequest_free(this_obj: LSPS1CreateOrderRequest) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1CreateOrderRequest_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1CreateOrderRequest) }; +} +#[allow(unused)] +impl LSPS1CreateOrderRequest { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1CreateOrderRequest { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1CreateOrderRequest { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1CreateOrderRequest { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The order made. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderRequest_get_order(this_ptr: &LSPS1CreateOrderRequest) -> crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams { + let mut inner_val = &mut this_ptr.get_native_mut_ref().order; + crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps1::msgs::LSPS1OrderParams<>) as *mut _) }, is_owned: false } +} +/// The order made. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderRequest_set_order(this_ptr: &mut LSPS1CreateOrderRequest, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.order = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The address where the LSP will send the funds if the order fails. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderRequest_get_refund_onchain_address(this_ptr: &LSPS1CreateOrderRequest) -> crate::c_types::derived::COption_AddressZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().refund_onchain_address; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_AddressZ::None } else { crate::c_types::derived::COption_AddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::Address::from_rust(&(*inner_val.as_ref().unwrap()).clone()) }) }; + local_inner_val +} +/// The address where the LSP will send the funds if the order fails. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderRequest_set_refund_onchain_address(this_ptr: &mut LSPS1CreateOrderRequest, mut val: crate::c_types::derived::COption_AddressZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_rust() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.refund_onchain_address = local_val; +} +/// Constructs a new LSPS1CreateOrderRequest given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderRequest_new(mut order_arg: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams, mut refund_onchain_address_arg: crate::c_types::derived::COption_AddressZ) -> LSPS1CreateOrderRequest { + let mut local_refund_onchain_address_arg = { /*refund_onchain_address_arg*/ let refund_onchain_address_arg_opt = refund_onchain_address_arg; if refund_onchain_address_arg_opt.is_none() { None } else { Some({ { { refund_onchain_address_arg_opt.take() }.into_rust() }})} }; + LSPS1CreateOrderRequest { inner: ObjOps::heap_alloc(nativeLSPS1CreateOrderRequest { + order: *unsafe { Box::from_raw(order_arg.take_inner()) }, + refund_onchain_address: local_refund_onchain_address_arg, + }), is_owned: true } +} +impl Clone for LSPS1CreateOrderRequest { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1CreateOrderRequest>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1CreateOrderRequest_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1CreateOrderRequest)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1CreateOrderRequest +pub extern "C" fn LSPS1CreateOrderRequest_clone(orig: &LSPS1CreateOrderRequest) -> LSPS1CreateOrderRequest { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1CreateOrderRequest object +pub extern "C" fn LSPS1CreateOrderRequest_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderRequest }).into()} +/// Checks if two LSPS1CreateOrderRequests contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderRequest_eq(a: &LSPS1CreateOrderRequest, b: &LSPS1CreateOrderRequest) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps1::msgs::LSPS1OrderParams as nativeLSPS1OrderParamsImport; +pub(crate) type nativeLSPS1OrderParams = nativeLSPS1OrderParamsImport; + +/// An object representing an bLIP-51 / LSPS1 channel order. +#[must_use] +#[repr(C)] +pub struct LSPS1OrderParams { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1OrderParams, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1OrderParams { + type Target = nativeLSPS1OrderParams; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1OrderParams { } +unsafe impl core::marker::Sync for LSPS1OrderParams { } +impl Drop for LSPS1OrderParams { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1OrderParams>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1OrderParams, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_free(this_obj: LSPS1OrderParams) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1OrderParams_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1OrderParams) }; +} +#[allow(unused)] +impl LSPS1OrderParams { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1OrderParams { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1OrderParams { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1OrderParams { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Indicates how many satoshi the LSP will provide on their side. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_get_lsp_balance_sat(this_ptr: &LSPS1OrderParams) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().lsp_balance_sat; + *inner_val +} +/// Indicates how many satoshi the LSP will provide on their side. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_set_lsp_balance_sat(this_ptr: &mut LSPS1OrderParams, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.lsp_balance_sat = val; +} +/// Indicates how many satoshi the client will provide on their side. +/// +/// The client sends these funds to the LSP, who will push them back to the client upon opening +/// the channel. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_get_client_balance_sat(this_ptr: &LSPS1OrderParams) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().client_balance_sat; + *inner_val +} +/// Indicates how many satoshi the client will provide on their side. +/// +/// The client sends these funds to the LSP, who will push them back to the client upon opening +/// the channel. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_set_client_balance_sat(this_ptr: &mut LSPS1OrderParams, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.client_balance_sat = val; +} +/// The number of confirmations the funding tx must have before the LSP sends `channel_ready`. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_get_required_channel_confirmations(this_ptr: &LSPS1OrderParams) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().required_channel_confirmations; + *inner_val +} +/// The number of confirmations the funding tx must have before the LSP sends `channel_ready`. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_set_required_channel_confirmations(this_ptr: &mut LSPS1OrderParams, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.required_channel_confirmations = val; +} +/// The maximum number of blocks the client wants to wait until the funding transaction is confirmed. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_get_funding_confirms_within_blocks(this_ptr: &LSPS1OrderParams) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_confirms_within_blocks; + *inner_val +} +/// The maximum number of blocks the client wants to wait until the funding transaction is confirmed. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_set_funding_confirms_within_blocks(this_ptr: &mut LSPS1OrderParams, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_confirms_within_blocks = val; +} +/// Indicates how long the channel is leased for in block time. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_get_channel_expiry_blocks(this_ptr: &LSPS1OrderParams) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_expiry_blocks; + *inner_val +} +/// Indicates how long the channel is leased for in block time. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_set_channel_expiry_blocks(this_ptr: &mut LSPS1OrderParams, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_expiry_blocks = val; +} +/// May contain arbitrary associated data like a coupon code or a authentication token. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_get_token(this_ptr: &LSPS1OrderParams) -> crate::c_types::derived::COption_StrZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().token; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_StrZ::None } else { crate::c_types::derived::COption_StrZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into() }) }; + local_inner_val +} +/// May contain arbitrary associated data like a coupon code or a authentication token. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_set_token(this_ptr: &mut LSPS1OrderParams, mut val: crate::c_types::derived::COption_StrZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_string() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.token = local_val; +} +/// Indicates if the channel should be announced to the network. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_get_announce_channel(this_ptr: &LSPS1OrderParams) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().announce_channel; + *inner_val +} +/// Indicates if the channel should be announced to the network. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_set_announce_channel(this_ptr: &mut LSPS1OrderParams, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announce_channel = val; +} +/// Constructs a new LSPS1OrderParams given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_new(mut lsp_balance_sat_arg: u64, mut client_balance_sat_arg: u64, mut required_channel_confirmations_arg: u16, mut funding_confirms_within_blocks_arg: u16, mut channel_expiry_blocks_arg: u32, mut token_arg: crate::c_types::derived::COption_StrZ, mut announce_channel_arg: bool) -> LSPS1OrderParams { + let mut local_token_arg = { /*token_arg*/ let token_arg_opt = token_arg; if token_arg_opt.is_none() { None } else { Some({ { { token_arg_opt.take() }.into_string() }})} }; + LSPS1OrderParams { inner: ObjOps::heap_alloc(nativeLSPS1OrderParams { + lsp_balance_sat: lsp_balance_sat_arg, + client_balance_sat: client_balance_sat_arg, + required_channel_confirmations: required_channel_confirmations_arg, + funding_confirms_within_blocks: funding_confirms_within_blocks_arg, + channel_expiry_blocks: channel_expiry_blocks_arg, + token: local_token_arg, + announce_channel: announce_channel_arg, + }), is_owned: true } +} +impl Clone for LSPS1OrderParams { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1OrderParams>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1OrderParams_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1OrderParams)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1OrderParams +pub extern "C" fn LSPS1OrderParams_clone(orig: &LSPS1OrderParams) -> LSPS1OrderParams { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1OrderParams object +pub extern "C" fn LSPS1OrderParams_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams }).into()} +/// Checks if two LSPS1OrderParamss contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1OrderParams_eq(a: &LSPS1OrderParams, b: &LSPS1OrderParams) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps1::msgs::LSPS1CreateOrderResponse as nativeLSPS1CreateOrderResponseImport; +pub(crate) type nativeLSPS1CreateOrderResponse = nativeLSPS1CreateOrderResponseImport; + +/// A response to a [`LSPS1CreateOrderRequest`]. +#[must_use] +#[repr(C)] +pub struct LSPS1CreateOrderResponse { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1CreateOrderResponse, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1CreateOrderResponse { + type Target = nativeLSPS1CreateOrderResponse; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1CreateOrderResponse { } +unsafe impl core::marker::Sync for LSPS1CreateOrderResponse { } +impl Drop for LSPS1CreateOrderResponse { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1CreateOrderResponse>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1CreateOrderResponse, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_free(this_obj: LSPS1CreateOrderResponse) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1CreateOrderResponse_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1CreateOrderResponse) }; +} +#[allow(unused)] +impl LSPS1CreateOrderResponse { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1CreateOrderResponse { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1CreateOrderResponse { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1CreateOrderResponse { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The id of the channel order. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_get_order_id(this_ptr: &LSPS1CreateOrderResponse) -> crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId { + let mut inner_val = &mut this_ptr.get_native_mut_ref().order_id; + crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps1::msgs::LSPS1OrderId<>) as *mut _) }, is_owned: false } +} +/// The id of the channel order. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_set_order_id(this_ptr: &mut LSPS1CreateOrderResponse, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.order_id = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The parameters of channel order. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_get_order(this_ptr: &LSPS1CreateOrderResponse) -> crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams { + let mut inner_val = &mut this_ptr.get_native_mut_ref().order; + crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps1::msgs::LSPS1OrderParams<>) as *mut _) }, is_owned: false } +} +/// The parameters of channel order. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_set_order(this_ptr: &mut LSPS1CreateOrderResponse, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.order = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The datetime when the order was created +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_get_created_at(this_ptr: &LSPS1CreateOrderResponse) -> crate::lightning_liquidity::lsps0::ser::LSPSDateTime { + let mut inner_val = &mut this_ptr.get_native_mut_ref().created_at; + crate::lightning_liquidity::lsps0::ser::LSPSDateTime { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps0::ser::LSPSDateTime<>) as *mut _) }, is_owned: false } +} +/// The datetime when the order was created +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_set_created_at(this_ptr: &mut LSPS1CreateOrderResponse, mut val: crate::lightning_liquidity::lsps0::ser::LSPSDateTime) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.created_at = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The current state of the order. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_get_order_state(this_ptr: &LSPS1CreateOrderResponse) -> crate::lightning_liquidity::lsps1::msgs::LSPS1OrderState { + let mut inner_val = &mut this_ptr.get_native_mut_ref().order_state; + crate::lightning_liquidity::lsps1::msgs::LSPS1OrderState::from_native(inner_val) +} +/// The current state of the order. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_set_order_state(this_ptr: &mut LSPS1CreateOrderResponse, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderState) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.order_state = val.into_native(); +} +/// Contains details about how to pay for the order. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_get_payment(this_ptr: &LSPS1CreateOrderResponse) -> crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment; + crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo<>) as *mut _) }, is_owned: false } +} +/// Contains details about how to pay for the order. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_set_payment(this_ptr: &mut LSPS1CreateOrderResponse, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Contains information about the channel state. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_get_channel(this_ptr: &LSPS1CreateOrderResponse) -> crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel; + let mut local_inner_val = crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// Contains information about the channel state. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_set_channel(this_ptr: &mut LSPS1CreateOrderResponse, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel = local_val; +} +/// Constructs a new LSPS1CreateOrderResponse given each field +/// +/// Note that channel_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_new(mut order_id_arg: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId, mut order_arg: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderParams, mut created_at_arg: crate::lightning_liquidity::lsps0::ser::LSPSDateTime, mut order_state_arg: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderState, mut payment_arg: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo, mut channel_arg: crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo) -> LSPS1CreateOrderResponse { + let mut local_channel_arg = if channel_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_arg.take_inner()) } }) }; + LSPS1CreateOrderResponse { inner: ObjOps::heap_alloc(nativeLSPS1CreateOrderResponse { + order_id: *unsafe { Box::from_raw(order_id_arg.take_inner()) }, + order: *unsafe { Box::from_raw(order_arg.take_inner()) }, + created_at: *unsafe { Box::from_raw(created_at_arg.take_inner()) }, + order_state: order_state_arg.into_native(), + payment: *unsafe { Box::from_raw(payment_arg.take_inner()) }, + channel: local_channel_arg, + }), is_owned: true } +} +impl Clone for LSPS1CreateOrderResponse { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1CreateOrderResponse>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1CreateOrderResponse_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1CreateOrderResponse)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1CreateOrderResponse +pub extern "C" fn LSPS1CreateOrderResponse_clone(orig: &LSPS1CreateOrderResponse) -> LSPS1CreateOrderResponse { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1CreateOrderResponse object +pub extern "C" fn LSPS1CreateOrderResponse_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderResponse }).into()} +/// Checks if two LSPS1CreateOrderResponses contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1CreateOrderResponse_eq(a: &LSPS1CreateOrderResponse, b: &LSPS1CreateOrderResponse) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// An object representing the status of an order. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS1OrderState { + /// The order has been created. + Created, + /// The LSP has opened the channel and published the funding transaction. + Completed, + /// The order failed. + Failed, +} +use lightning_liquidity::lsps1::msgs::LSPS1OrderState as LSPS1OrderStateImport; +pub(crate) type nativeLSPS1OrderState = LSPS1OrderStateImport; + +impl LSPS1OrderState { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS1OrderState { + match self { + LSPS1OrderState::Created => nativeLSPS1OrderState::Created, + LSPS1OrderState::Completed => nativeLSPS1OrderState::Completed, + LSPS1OrderState::Failed => nativeLSPS1OrderState::Failed, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS1OrderState { + match self { + LSPS1OrderState::Created => nativeLSPS1OrderState::Created, + LSPS1OrderState::Completed => nativeLSPS1OrderState::Completed, + LSPS1OrderState::Failed => nativeLSPS1OrderState::Failed, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS1OrderStateImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS1OrderState) }; + match native { + nativeLSPS1OrderState::Created => LSPS1OrderState::Created, + nativeLSPS1OrderState::Completed => LSPS1OrderState::Completed, + nativeLSPS1OrderState::Failed => LSPS1OrderState::Failed, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS1OrderState) -> Self { + match native { + nativeLSPS1OrderState::Created => LSPS1OrderState::Created, + nativeLSPS1OrderState::Completed => LSPS1OrderState::Completed, + nativeLSPS1OrderState::Failed => LSPS1OrderState::Failed, + } + } +} +/// Creates a copy of the LSPS1OrderState +#[no_mangle] +pub extern "C" fn LSPS1OrderState_clone(orig: &LSPS1OrderState) -> LSPS1OrderState { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1OrderState_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS1OrderState)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1OrderState_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS1OrderState) }; +} +#[no_mangle] +/// Utility method to constructs a new Created-variant LSPS1OrderState +pub extern "C" fn LSPS1OrderState_created() -> LSPS1OrderState { + LSPS1OrderState::Created} +#[no_mangle] +/// Utility method to constructs a new Completed-variant LSPS1OrderState +pub extern "C" fn LSPS1OrderState_completed() -> LSPS1OrderState { + LSPS1OrderState::Completed} +#[no_mangle] +/// Utility method to constructs a new Failed-variant LSPS1OrderState +pub extern "C" fn LSPS1OrderState_failed() -> LSPS1OrderState { + LSPS1OrderState::Failed} +/// Get a string which allows debug introspection of a LSPS1OrderState object +pub extern "C" fn LSPS1OrderState_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1OrderState }).into()} +/// Checks if two LSPS1OrderStates contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS1OrderState_eq(a: &LSPS1OrderState, b: &LSPS1OrderState) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} + +use lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo as nativeLSPS1PaymentInfoImport; +pub(crate) type nativeLSPS1PaymentInfo = nativeLSPS1PaymentInfoImport; + +/// Details regarding how to pay for an order. +#[must_use] +#[repr(C)] +pub struct LSPS1PaymentInfo { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1PaymentInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1PaymentInfo { + type Target = nativeLSPS1PaymentInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1PaymentInfo { } +unsafe impl core::marker::Sync for LSPS1PaymentInfo { } +impl Drop for LSPS1PaymentInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1PaymentInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1PaymentInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1PaymentInfo_free(this_obj: LSPS1PaymentInfo) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1PaymentInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1PaymentInfo) }; +} +#[allow(unused)] +impl LSPS1PaymentInfo { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1PaymentInfo { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1PaymentInfo { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1PaymentInfo { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// A Lightning payment using BOLT 11. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn LSPS1PaymentInfo_get_bolt11(this_ptr: &LSPS1PaymentInfo) -> crate::lightning_liquidity::lsps1::msgs::LSPS1Bolt11PaymentInfo { + let mut inner_val = &mut this_ptr.get_native_mut_ref().bolt11; + let mut local_inner_val = crate::lightning_liquidity::lsps1::msgs::LSPS1Bolt11PaymentInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning_liquidity::lsps1::msgs::LSPS1Bolt11PaymentInfo<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// A Lightning payment using BOLT 11. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn LSPS1PaymentInfo_set_bolt11(this_ptr: &mut LSPS1PaymentInfo, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1Bolt11PaymentInfo) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bolt11 = local_val; +} +/// An onchain payment. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn LSPS1PaymentInfo_get_onchain(this_ptr: &LSPS1PaymentInfo) -> crate::lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo { + let mut inner_val = &mut this_ptr.get_native_mut_ref().onchain; + let mut local_inner_val = crate::lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// An onchain payment. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn LSPS1PaymentInfo_set_onchain(this_ptr: &mut LSPS1PaymentInfo, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onchain = local_val; +} +/// Constructs a new LSPS1PaymentInfo given each field +/// +/// Note that bolt11_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Note that onchain_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1PaymentInfo_new(mut bolt11_arg: crate::lightning_liquidity::lsps1::msgs::LSPS1Bolt11PaymentInfo, mut onchain_arg: crate::lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo) -> LSPS1PaymentInfo { + let mut local_bolt11_arg = if bolt11_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(bolt11_arg.take_inner()) } }) }; + let mut local_onchain_arg = if onchain_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onchain_arg.take_inner()) } }) }; + LSPS1PaymentInfo { inner: ObjOps::heap_alloc(nativeLSPS1PaymentInfo { + bolt11: local_bolt11_arg, + onchain: local_onchain_arg, + }), is_owned: true } +} +impl Clone for LSPS1PaymentInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1PaymentInfo>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1PaymentInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1PaymentInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1PaymentInfo +pub extern "C" fn LSPS1PaymentInfo_clone(orig: &LSPS1PaymentInfo) -> LSPS1PaymentInfo { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1PaymentInfo object +pub extern "C" fn LSPS1PaymentInfo_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo }).into()} +/// Checks if two LSPS1PaymentInfos contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1PaymentInfo_eq(a: &LSPS1PaymentInfo, b: &LSPS1PaymentInfo) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps1::msgs::LSPS1Bolt11PaymentInfo as nativeLSPS1Bolt11PaymentInfoImport; +pub(crate) type nativeLSPS1Bolt11PaymentInfo = nativeLSPS1Bolt11PaymentInfoImport; + +/// A Lightning payment using BOLT 11. +#[must_use] +#[repr(C)] +pub struct LSPS1Bolt11PaymentInfo { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1Bolt11PaymentInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1Bolt11PaymentInfo { + type Target = nativeLSPS1Bolt11PaymentInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1Bolt11PaymentInfo { } +unsafe impl core::marker::Sync for LSPS1Bolt11PaymentInfo { } +impl Drop for LSPS1Bolt11PaymentInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1Bolt11PaymentInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1Bolt11PaymentInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_free(this_obj: LSPS1Bolt11PaymentInfo) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1Bolt11PaymentInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1Bolt11PaymentInfo) }; +} +#[allow(unused)] +impl LSPS1Bolt11PaymentInfo { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1Bolt11PaymentInfo { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1Bolt11PaymentInfo { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1Bolt11PaymentInfo { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Indicates the current state of the payment. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_get_state(this_ptr: &LSPS1Bolt11PaymentInfo) -> crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentState { + let mut inner_val = &mut this_ptr.get_native_mut_ref().state; + crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentState::from_native(inner_val) +} +/// Indicates the current state of the payment. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_set_state(this_ptr: &mut LSPS1Bolt11PaymentInfo, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentState) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.state = val.into_native(); +} +/// The datetime when the payment option expires. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_get_expires_at(this_ptr: &LSPS1Bolt11PaymentInfo) -> crate::lightning_liquidity::lsps0::ser::LSPSDateTime { + let mut inner_val = &mut this_ptr.get_native_mut_ref().expires_at; + crate::lightning_liquidity::lsps0::ser::LSPSDateTime { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps0::ser::LSPSDateTime<>) as *mut _) }, is_owned: false } +} +/// The datetime when the payment option expires. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_set_expires_at(this_ptr: &mut LSPS1Bolt11PaymentInfo, mut val: crate::lightning_liquidity::lsps0::ser::LSPSDateTime) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.expires_at = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The total fee the LSP will charge to open this channel in satoshi. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_get_fee_total_sat(this_ptr: &LSPS1Bolt11PaymentInfo) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_total_sat; + *inner_val +} +/// The total fee the LSP will charge to open this channel in satoshi. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_set_fee_total_sat(this_ptr: &mut LSPS1Bolt11PaymentInfo, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_total_sat = val; +} +/// The amount the client needs to pay to have the requested channel openend. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_get_order_total_sat(this_ptr: &LSPS1Bolt11PaymentInfo) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().order_total_sat; + *inner_val +} +/// The amount the client needs to pay to have the requested channel openend. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_set_order_total_sat(this_ptr: &mut LSPS1Bolt11PaymentInfo, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.order_total_sat = val; +} +/// A BOLT11 invoice the client can pay to have to channel opened. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_get_invoice(this_ptr: &LSPS1Bolt11PaymentInfo) -> crate::lightning_invoice::Bolt11Invoice { + let mut inner_val = &mut this_ptr.get_native_mut_ref().invoice; + crate::lightning_invoice::Bolt11Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_invoice::Bolt11Invoice<>) as *mut _) }, is_owned: false } +} +/// A BOLT11 invoice the client can pay to have to channel opened. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_set_invoice(this_ptr: &mut LSPS1Bolt11PaymentInfo, mut val: crate::lightning_invoice::Bolt11Invoice) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.invoice = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new LSPS1Bolt11PaymentInfo given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_new(mut state_arg: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentState, mut expires_at_arg: crate::lightning_liquidity::lsps0::ser::LSPSDateTime, mut fee_total_sat_arg: u64, mut order_total_sat_arg: u64, mut invoice_arg: crate::lightning_invoice::Bolt11Invoice) -> LSPS1Bolt11PaymentInfo { + LSPS1Bolt11PaymentInfo { inner: ObjOps::heap_alloc(nativeLSPS1Bolt11PaymentInfo { + state: state_arg.into_native(), + expires_at: *unsafe { Box::from_raw(expires_at_arg.take_inner()) }, + fee_total_sat: fee_total_sat_arg, + order_total_sat: order_total_sat_arg, + invoice: *unsafe { Box::from_raw(invoice_arg.take_inner()) }, + }), is_owned: true } +} +impl Clone for LSPS1Bolt11PaymentInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1Bolt11PaymentInfo>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1Bolt11PaymentInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1Bolt11PaymentInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1Bolt11PaymentInfo +pub extern "C" fn LSPS1Bolt11PaymentInfo_clone(orig: &LSPS1Bolt11PaymentInfo) -> LSPS1Bolt11PaymentInfo { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1Bolt11PaymentInfo object +pub extern "C" fn LSPS1Bolt11PaymentInfo_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1Bolt11PaymentInfo }).into()} +/// Checks if two LSPS1Bolt11PaymentInfos contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1Bolt11PaymentInfo_eq(a: &LSPS1Bolt11PaymentInfo, b: &LSPS1Bolt11PaymentInfo) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo as nativeLSPS1OnchainPaymentInfoImport; +pub(crate) type nativeLSPS1OnchainPaymentInfo = nativeLSPS1OnchainPaymentInfoImport; + +/// An onchain payment. +#[must_use] +#[repr(C)] +pub struct LSPS1OnchainPaymentInfo { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1OnchainPaymentInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1OnchainPaymentInfo { + type Target = nativeLSPS1OnchainPaymentInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1OnchainPaymentInfo { } +unsafe impl core::marker::Sync for LSPS1OnchainPaymentInfo { } +impl Drop for LSPS1OnchainPaymentInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1OnchainPaymentInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1OnchainPaymentInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_free(this_obj: LSPS1OnchainPaymentInfo) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1OnchainPaymentInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1OnchainPaymentInfo) }; +} +#[allow(unused)] +impl LSPS1OnchainPaymentInfo { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1OnchainPaymentInfo { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1OnchainPaymentInfo { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1OnchainPaymentInfo { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Indicates the current state of the payment. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_get_state(this_ptr: &LSPS1OnchainPaymentInfo) -> crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentState { + let mut inner_val = &mut this_ptr.get_native_mut_ref().state; + crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentState::from_native(inner_val) +} +/// Indicates the current state of the payment. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_set_state(this_ptr: &mut LSPS1OnchainPaymentInfo, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentState) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.state = val.into_native(); +} +/// The datetime when the payment option expires. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_get_expires_at(this_ptr: &LSPS1OnchainPaymentInfo) -> crate::lightning_liquidity::lsps0::ser::LSPSDateTime { + let mut inner_val = &mut this_ptr.get_native_mut_ref().expires_at; + crate::lightning_liquidity::lsps0::ser::LSPSDateTime { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps0::ser::LSPSDateTime<>) as *mut _) }, is_owned: false } +} +/// The datetime when the payment option expires. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_set_expires_at(this_ptr: &mut LSPS1OnchainPaymentInfo, mut val: crate::lightning_liquidity::lsps0::ser::LSPSDateTime) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.expires_at = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The total fee the LSP will charge to open this channel in satoshi. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_get_fee_total_sat(this_ptr: &LSPS1OnchainPaymentInfo) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_total_sat; + *inner_val +} +/// The total fee the LSP will charge to open this channel in satoshi. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_set_fee_total_sat(this_ptr: &mut LSPS1OnchainPaymentInfo, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_total_sat = val; +} +/// The amount the client needs to pay to have the requested channel openend. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_get_order_total_sat(this_ptr: &LSPS1OnchainPaymentInfo) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().order_total_sat; + *inner_val +} +/// The amount the client needs to pay to have the requested channel openend. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_set_order_total_sat(this_ptr: &mut LSPS1OnchainPaymentInfo, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.order_total_sat = val; +} +/// An on-chain address the client can send [`Self::order_total_sat`] to to have the channel +/// opened. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_get_address(this_ptr: &LSPS1OnchainPaymentInfo) -> crate::c_types::Address { + let mut inner_val = &mut this_ptr.get_native_mut_ref().address; + crate::c_types::Address::from_rust(inner_val) +} +/// An on-chain address the client can send [`Self::order_total_sat`] to to have the channel +/// opened. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_set_address(this_ptr: &mut LSPS1OnchainPaymentInfo, mut val: crate::c_types::Address) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.address = val.into_rust(); +} +/// The minimum number of block confirmations that are required for the on-chain payment to be +/// considered confirmed. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_get_min_onchain_payment_confirmations(this_ptr: &LSPS1OnchainPaymentInfo) -> crate::c_types::derived::COption_u16Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_onchain_payment_confirmations; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u16Z::None } else { crate::c_types::derived::COption_u16Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The minimum number of block confirmations that are required for the on-chain payment to be +/// considered confirmed. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_set_min_onchain_payment_confirmations(this_ptr: &mut LSPS1OnchainPaymentInfo, mut val: crate::c_types::derived::COption_u16Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_onchain_payment_confirmations = local_val; +} +/// The address where the LSP will send the funds if the order fails. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_get_refund_onchain_address(this_ptr: &LSPS1OnchainPaymentInfo) -> crate::c_types::derived::COption_AddressZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().refund_onchain_address; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_AddressZ::None } else { crate::c_types::derived::COption_AddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::Address::from_rust(&(*inner_val.as_ref().unwrap()).clone()) }) }; + local_inner_val +} +/// The address where the LSP will send the funds if the order fails. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_set_refund_onchain_address(this_ptr: &mut LSPS1OnchainPaymentInfo, mut val: crate::c_types::derived::COption_AddressZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_rust() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.refund_onchain_address = local_val; +} +impl Clone for LSPS1OnchainPaymentInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1OnchainPaymentInfo>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1OnchainPaymentInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1OnchainPaymentInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1OnchainPaymentInfo +pub extern "C" fn LSPS1OnchainPaymentInfo_clone(orig: &LSPS1OnchainPaymentInfo) -> LSPS1OnchainPaymentInfo { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1OnchainPaymentInfo object +pub extern "C" fn LSPS1OnchainPaymentInfo_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo }).into()} +/// Checks if two LSPS1OnchainPaymentInfos contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPaymentInfo_eq(a: &LSPS1OnchainPaymentInfo, b: &LSPS1OnchainPaymentInfo) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// The state of a payment. +/// +/// *Note*: Previously, the spec also knew a `CANCELLED` state for BOLT11 payments, which has since +/// been deprecated and `REFUNDED` should be used instead. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS1PaymentState { + /// A payment is expected. + ExpectPayment, + /// A sufficient payment has been received. + Paid, + /// The payment has been refunded. + Refunded, +} +use lightning_liquidity::lsps1::msgs::LSPS1PaymentState as LSPS1PaymentStateImport; +pub(crate) type nativeLSPS1PaymentState = LSPS1PaymentStateImport; + +impl LSPS1PaymentState { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS1PaymentState { + match self { + LSPS1PaymentState::ExpectPayment => nativeLSPS1PaymentState::ExpectPayment, + LSPS1PaymentState::Paid => nativeLSPS1PaymentState::Paid, + LSPS1PaymentState::Refunded => nativeLSPS1PaymentState::Refunded, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS1PaymentState { + match self { + LSPS1PaymentState::ExpectPayment => nativeLSPS1PaymentState::ExpectPayment, + LSPS1PaymentState::Paid => nativeLSPS1PaymentState::Paid, + LSPS1PaymentState::Refunded => nativeLSPS1PaymentState::Refunded, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS1PaymentStateImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS1PaymentState) }; + match native { + nativeLSPS1PaymentState::ExpectPayment => LSPS1PaymentState::ExpectPayment, + nativeLSPS1PaymentState::Paid => LSPS1PaymentState::Paid, + nativeLSPS1PaymentState::Refunded => LSPS1PaymentState::Refunded, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS1PaymentState) -> Self { + match native { + nativeLSPS1PaymentState::ExpectPayment => LSPS1PaymentState::ExpectPayment, + nativeLSPS1PaymentState::Paid => LSPS1PaymentState::Paid, + nativeLSPS1PaymentState::Refunded => LSPS1PaymentState::Refunded, + } + } +} +/// Creates a copy of the LSPS1PaymentState +#[no_mangle] +pub extern "C" fn LSPS1PaymentState_clone(orig: &LSPS1PaymentState) -> LSPS1PaymentState { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1PaymentState_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS1PaymentState)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1PaymentState_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS1PaymentState) }; +} +#[no_mangle] +/// Utility method to constructs a new ExpectPayment-variant LSPS1PaymentState +pub extern "C" fn LSPS1PaymentState_expect_payment() -> LSPS1PaymentState { + LSPS1PaymentState::ExpectPayment} +#[no_mangle] +/// Utility method to constructs a new Paid-variant LSPS1PaymentState +pub extern "C" fn LSPS1PaymentState_paid() -> LSPS1PaymentState { + LSPS1PaymentState::Paid} +#[no_mangle] +/// Utility method to constructs a new Refunded-variant LSPS1PaymentState +pub extern "C" fn LSPS1PaymentState_refunded() -> LSPS1PaymentState { + LSPS1PaymentState::Refunded} +/// Get a string which allows debug introspection of a LSPS1PaymentState object +pub extern "C" fn LSPS1PaymentState_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1PaymentState }).into()} +/// Checks if two LSPS1PaymentStates contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS1PaymentState_eq(a: &LSPS1PaymentState, b: &LSPS1PaymentState) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} + +use lightning_liquidity::lsps1::msgs::LSPS1OnchainPayment as nativeLSPS1OnchainPaymentImport; +pub(crate) type nativeLSPS1OnchainPayment = nativeLSPS1OnchainPaymentImport; + +/// Details regarding a detected on-chain payment. +#[must_use] +#[repr(C)] +pub struct LSPS1OnchainPayment { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1OnchainPayment, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1OnchainPayment { + type Target = nativeLSPS1OnchainPayment; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1OnchainPayment { } +unsafe impl core::marker::Sync for LSPS1OnchainPayment { } +impl Drop for LSPS1OnchainPayment { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1OnchainPayment>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1OnchainPayment, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPayment_free(this_obj: LSPS1OnchainPayment) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1OnchainPayment_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1OnchainPayment) }; +} +#[allow(unused)] +impl LSPS1OnchainPayment { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1OnchainPayment { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1OnchainPayment { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1OnchainPayment { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The outpoint of the payment. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPayment_get_outpoint(this_ptr: &LSPS1OnchainPayment) -> crate::c_types::Str { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint; + inner_val.as_str().into() +} +/// The outpoint of the payment. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPayment_set_outpoint(this_ptr: &mut LSPS1OnchainPayment, mut val: crate::c_types::Str) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = val.into_string(); +} +/// The amount of satoshi paid. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPayment_get_sat(this_ptr: &LSPS1OnchainPayment) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().sat; + *inner_val +} +/// The amount of satoshi paid. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPayment_set_sat(this_ptr: &mut LSPS1OnchainPayment, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sat = val; +} +/// Indicates if the LSP regards the transaction as sufficiently confirmed. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPayment_get_confirmed(this_ptr: &LSPS1OnchainPayment) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmed; + *inner_val +} +/// Indicates if the LSP regards the transaction as sufficiently confirmed. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPayment_set_confirmed(this_ptr: &mut LSPS1OnchainPayment, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmed = val; +} +/// Constructs a new LSPS1OnchainPayment given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1OnchainPayment_new(mut outpoint_arg: crate::c_types::Str, mut sat_arg: u64, mut confirmed_arg: bool) -> LSPS1OnchainPayment { + LSPS1OnchainPayment { inner: ObjOps::heap_alloc(nativeLSPS1OnchainPayment { + outpoint: outpoint_arg.into_string(), + sat: sat_arg, + confirmed: confirmed_arg, + }), is_owned: true } +} +impl Clone for LSPS1OnchainPayment { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1OnchainPayment>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1OnchainPayment_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1OnchainPayment)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1OnchainPayment +pub extern "C" fn LSPS1OnchainPayment_clone(orig: &LSPS1OnchainPayment) -> LSPS1OnchainPayment { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1OnchainPayment object +pub extern "C" fn LSPS1OnchainPayment_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1OnchainPayment }).into()} +/// Checks if two LSPS1OnchainPayments contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1OnchainPayment_eq(a: &LSPS1OnchainPayment, b: &LSPS1OnchainPayment) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo as nativeLSPS1ChannelInfoImport; +pub(crate) type nativeLSPS1ChannelInfo = nativeLSPS1ChannelInfoImport; + +/// Details regarding the state of an ordered channel. +#[must_use] +#[repr(C)] +pub struct LSPS1ChannelInfo { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1ChannelInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1ChannelInfo { + type Target = nativeLSPS1ChannelInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1ChannelInfo { } +unsafe impl core::marker::Sync for LSPS1ChannelInfo { } +impl Drop for LSPS1ChannelInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1ChannelInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1ChannelInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1ChannelInfo_free(this_obj: LSPS1ChannelInfo) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1ChannelInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1ChannelInfo) }; +} +#[allow(unused)] +impl LSPS1ChannelInfo { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1ChannelInfo { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1ChannelInfo { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1ChannelInfo { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The datetime when the funding transaction has been published. +#[no_mangle] +pub extern "C" fn LSPS1ChannelInfo_get_funded_at(this_ptr: &LSPS1ChannelInfo) -> crate::lightning_liquidity::lsps0::ser::LSPSDateTime { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funded_at; + crate::lightning_liquidity::lsps0::ser::LSPSDateTime { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps0::ser::LSPSDateTime<>) as *mut _) }, is_owned: false } +} +/// The datetime when the funding transaction has been published. +#[no_mangle] +pub extern "C" fn LSPS1ChannelInfo_set_funded_at(this_ptr: &mut LSPS1ChannelInfo, mut val: crate::lightning_liquidity::lsps0::ser::LSPSDateTime) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funded_at = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The outpoint of the funding transaction. +#[no_mangle] +pub extern "C" fn LSPS1ChannelInfo_get_funding_outpoint(this_ptr: &LSPS1ChannelInfo) -> crate::lightning::chain::transaction::OutPoint { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_outpoint; + crate::c_types::bitcoin_to_C_outpoint(inner_val) +} +/// The outpoint of the funding transaction. +#[no_mangle] +pub extern "C" fn LSPS1ChannelInfo_set_funding_outpoint(this_ptr: &mut LSPS1ChannelInfo, mut val: crate::lightning::chain::transaction::OutPoint) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_outpoint = crate::c_types::C_to_bitcoin_outpoint(val); +} +/// The earliest datetime when the channel may be closed by the LSP. +#[no_mangle] +pub extern "C" fn LSPS1ChannelInfo_get_expires_at(this_ptr: &LSPS1ChannelInfo) -> crate::lightning_liquidity::lsps0::ser::LSPSDateTime { + let mut inner_val = &mut this_ptr.get_native_mut_ref().expires_at; + crate::lightning_liquidity::lsps0::ser::LSPSDateTime { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps0::ser::LSPSDateTime<>) as *mut _) }, is_owned: false } +} +/// The earliest datetime when the channel may be closed by the LSP. +#[no_mangle] +pub extern "C" fn LSPS1ChannelInfo_set_expires_at(this_ptr: &mut LSPS1ChannelInfo, mut val: crate::lightning_liquidity::lsps0::ser::LSPSDateTime) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.expires_at = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new LSPS1ChannelInfo given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1ChannelInfo_new(mut funded_at_arg: crate::lightning_liquidity::lsps0::ser::LSPSDateTime, mut funding_outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut expires_at_arg: crate::lightning_liquidity::lsps0::ser::LSPSDateTime) -> LSPS1ChannelInfo { + LSPS1ChannelInfo { inner: ObjOps::heap_alloc(nativeLSPS1ChannelInfo { + funded_at: *unsafe { Box::from_raw(funded_at_arg.take_inner()) }, + funding_outpoint: crate::c_types::C_to_bitcoin_outpoint(funding_outpoint_arg), + expires_at: *unsafe { Box::from_raw(expires_at_arg.take_inner()) }, + }), is_owned: true } +} +impl Clone for LSPS1ChannelInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1ChannelInfo>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1ChannelInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1ChannelInfo +pub extern "C" fn LSPS1ChannelInfo_clone(orig: &LSPS1ChannelInfo) -> LSPS1ChannelInfo { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1ChannelInfo object +pub extern "C" fn LSPS1ChannelInfo_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1ChannelInfo }).into()} +/// Checks if two LSPS1ChannelInfos contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1ChannelInfo_eq(a: &LSPS1ChannelInfo, b: &LSPS1ChannelInfo) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps1::msgs::LSPS1GetOrderRequest as nativeLSPS1GetOrderRequestImport; +pub(crate) type nativeLSPS1GetOrderRequest = nativeLSPS1GetOrderRequestImport; + +/// A request made to an LSP to retrieve information about an previously made order. +/// +/// Please refer to the [bLIP-51 / LSPS1 +/// specification](https://github.com/lightning/blips/blob/master/blip-0051.md#21-lsps1get_order) +/// for more information. +#[must_use] +#[repr(C)] +pub struct LSPS1GetOrderRequest { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS1GetOrderRequest, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS1GetOrderRequest { + type Target = nativeLSPS1GetOrderRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS1GetOrderRequest { } +unsafe impl core::marker::Sync for LSPS1GetOrderRequest { } +impl Drop for LSPS1GetOrderRequest { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS1GetOrderRequest>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS1GetOrderRequest, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS1GetOrderRequest_free(this_obj: LSPS1GetOrderRequest) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1GetOrderRequest_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS1GetOrderRequest) }; +} +#[allow(unused)] +impl LSPS1GetOrderRequest { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS1GetOrderRequest { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS1GetOrderRequest { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS1GetOrderRequest { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The id of the order. +#[no_mangle] +pub extern "C" fn LSPS1GetOrderRequest_get_order_id(this_ptr: &LSPS1GetOrderRequest) -> crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId { + let mut inner_val = &mut this_ptr.get_native_mut_ref().order_id; + crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps1::msgs::LSPS1OrderId<>) as *mut _) }, is_owned: false } +} +/// The id of the order. +#[no_mangle] +pub extern "C" fn LSPS1GetOrderRequest_set_order_id(this_ptr: &mut LSPS1GetOrderRequest, mut val: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.order_id = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new LSPS1GetOrderRequest given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS1GetOrderRequest_new(mut order_id_arg: crate::lightning_liquidity::lsps1::msgs::LSPS1OrderId) -> LSPS1GetOrderRequest { + LSPS1GetOrderRequest { inner: ObjOps::heap_alloc(nativeLSPS1GetOrderRequest { + order_id: *unsafe { Box::from_raw(order_id_arg.take_inner()) }, + }), is_owned: true } +} +impl Clone for LSPS1GetOrderRequest { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS1GetOrderRequest>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1GetOrderRequest_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS1GetOrderRequest)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS1GetOrderRequest +pub extern "C" fn LSPS1GetOrderRequest_clone(orig: &LSPS1GetOrderRequest) -> LSPS1GetOrderRequest { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS1GetOrderRequest object +pub extern "C" fn LSPS1GetOrderRequest_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1GetOrderRequest }).into()} +/// Checks if two LSPS1GetOrderRequests contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS1GetOrderRequest_eq(a: &LSPS1GetOrderRequest, b: &LSPS1GetOrderRequest) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// An enum that captures all the valid JSON-RPC requests in the bLIP-51 / LSPS1 protocol. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS1Request { + /// A request to learn about the options supported by the LSP. + GetInfo( + crate::lightning_liquidity::lsps1::msgs::LSPS1GetInfoRequest), + /// A request to create a channel order. + CreateOrder( + crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderRequest), + /// A request to query a previously created channel order. + GetOrder( + crate::lightning_liquidity::lsps1::msgs::LSPS1GetOrderRequest), +} +use lightning_liquidity::lsps1::msgs::LSPS1Request as LSPS1RequestImport; +pub(crate) type nativeLSPS1Request = LSPS1RequestImport; + +impl LSPS1Request { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS1Request { + match self { + LSPS1Request::GetInfo (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS1Request::GetInfo ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS1Request::CreateOrder (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS1Request::CreateOrder ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS1Request::GetOrder (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS1Request::GetOrder ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS1Request { + match self { + LSPS1Request::GetInfo (mut a, ) => { + nativeLSPS1Request::GetInfo ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS1Request::CreateOrder (mut a, ) => { + nativeLSPS1Request::CreateOrder ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS1Request::GetOrder (mut a, ) => { + nativeLSPS1Request::GetOrder ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS1RequestImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS1Request) }; + match native { + nativeLSPS1Request::GetInfo (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS1Request::GetInfo ( + crate::lightning_liquidity::lsps1::msgs::LSPS1GetInfoRequest { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS1Request::CreateOrder (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS1Request::CreateOrder ( + crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderRequest { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS1Request::GetOrder (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS1Request::GetOrder ( + crate::lightning_liquidity::lsps1::msgs::LSPS1GetOrderRequest { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS1Request) -> Self { + match native { + nativeLSPS1Request::GetInfo (mut a, ) => { + LSPS1Request::GetInfo ( + crate::lightning_liquidity::lsps1::msgs::LSPS1GetInfoRequest { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS1Request::CreateOrder (mut a, ) => { + LSPS1Request::CreateOrder ( + crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderRequest { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS1Request::GetOrder (mut a, ) => { + LSPS1Request::GetOrder ( + crate::lightning_liquidity::lsps1::msgs::LSPS1GetOrderRequest { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the LSPS1Request +#[no_mangle] +pub extern "C" fn LSPS1Request_free(this_ptr: LSPS1Request) { } +/// Creates a copy of the LSPS1Request +#[no_mangle] +pub extern "C" fn LSPS1Request_clone(orig: &LSPS1Request) -> LSPS1Request { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1Request_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS1Request)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1Request_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS1Request) }; +} +#[no_mangle] +/// Utility method to constructs a new GetInfo-variant LSPS1Request +pub extern "C" fn LSPS1Request_get_info(a: crate::lightning_liquidity::lsps1::msgs::LSPS1GetInfoRequest) -> LSPS1Request { + LSPS1Request::GetInfo(a, ) +} +#[no_mangle] +/// Utility method to constructs a new CreateOrder-variant LSPS1Request +pub extern "C" fn LSPS1Request_create_order(a: crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderRequest) -> LSPS1Request { + LSPS1Request::CreateOrder(a, ) +} +#[no_mangle] +/// Utility method to constructs a new GetOrder-variant LSPS1Request +pub extern "C" fn LSPS1Request_get_order(a: crate::lightning_liquidity::lsps1::msgs::LSPS1GetOrderRequest) -> LSPS1Request { + LSPS1Request::GetOrder(a, ) +} +/// Get a string which allows debug introspection of a LSPS1Request object +pub extern "C" fn LSPS1Request_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1Request }).into()} +/// Checks if two LSPS1Requests contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS1Request_eq(a: &LSPS1Request, b: &LSPS1Request) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +/// An enum that captures all the valid JSON-RPC responses in the bLIP-51 / LSPS1 protocol. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS1Response { + /// A successful response to a [`LSPS1GetInfoRequest`]. + GetInfo( + crate::lightning_liquidity::lsps1::msgs::LSPS1GetInfoResponse), + /// An error response to a [`LSPS1GetInfoRequest`]. + GetInfoError( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError), + /// A successful response to a [`LSPS1CreateOrderRequest`]. + CreateOrder( + crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderResponse), + /// An error response to a [`LSPS1CreateOrderRequest`]. + CreateOrderError( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError), + /// A successful response to a [`LSPS1GetOrderRequest`]. + GetOrder( + crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderResponse), + /// An error response to a [`LSPS1GetOrderRequest`]. + GetOrderError( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError), +} +use lightning_liquidity::lsps1::msgs::LSPS1Response as LSPS1ResponseImport; +pub(crate) type nativeLSPS1Response = LSPS1ResponseImport; + +impl LSPS1Response { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS1Response { + match self { + LSPS1Response::GetInfo (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS1Response::GetInfo ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS1Response::GetInfoError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS1Response::GetInfoError ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS1Response::CreateOrder (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS1Response::CreateOrder ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS1Response::CreateOrderError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS1Response::CreateOrderError ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS1Response::GetOrder (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS1Response::GetOrder ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS1Response::GetOrderError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS1Response::GetOrderError ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS1Response { + match self { + LSPS1Response::GetInfo (mut a, ) => { + nativeLSPS1Response::GetInfo ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS1Response::GetInfoError (mut a, ) => { + nativeLSPS1Response::GetInfoError ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS1Response::CreateOrder (mut a, ) => { + nativeLSPS1Response::CreateOrder ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS1Response::CreateOrderError (mut a, ) => { + nativeLSPS1Response::CreateOrderError ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS1Response::GetOrder (mut a, ) => { + nativeLSPS1Response::GetOrder ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS1Response::GetOrderError (mut a, ) => { + nativeLSPS1Response::GetOrderError ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS1ResponseImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS1Response) }; + match native { + nativeLSPS1Response::GetInfo (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS1Response::GetInfo ( + crate::lightning_liquidity::lsps1::msgs::LSPS1GetInfoResponse { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS1Response::GetInfoError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS1Response::GetInfoError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS1Response::CreateOrder (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS1Response::CreateOrder ( + crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderResponse { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS1Response::CreateOrderError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS1Response::CreateOrderError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS1Response::GetOrder (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS1Response::GetOrder ( + crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderResponse { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS1Response::GetOrderError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS1Response::GetOrderError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS1Response) -> Self { + match native { + nativeLSPS1Response::GetInfo (mut a, ) => { + LSPS1Response::GetInfo ( + crate::lightning_liquidity::lsps1::msgs::LSPS1GetInfoResponse { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS1Response::GetInfoError (mut a, ) => { + LSPS1Response::GetInfoError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS1Response::CreateOrder (mut a, ) => { + LSPS1Response::CreateOrder ( + crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderResponse { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS1Response::CreateOrderError (mut a, ) => { + LSPS1Response::CreateOrderError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS1Response::GetOrder (mut a, ) => { + LSPS1Response::GetOrder ( + crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderResponse { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS1Response::GetOrderError (mut a, ) => { + LSPS1Response::GetOrderError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the LSPS1Response +#[no_mangle] +pub extern "C" fn LSPS1Response_free(this_ptr: LSPS1Response) { } +/// Creates a copy of the LSPS1Response +#[no_mangle] +pub extern "C" fn LSPS1Response_clone(orig: &LSPS1Response) -> LSPS1Response { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1Response_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS1Response)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1Response_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS1Response) }; +} +#[no_mangle] +/// Utility method to constructs a new GetInfo-variant LSPS1Response +pub extern "C" fn LSPS1Response_get_info(a: crate::lightning_liquidity::lsps1::msgs::LSPS1GetInfoResponse) -> LSPS1Response { + LSPS1Response::GetInfo(a, ) +} +#[no_mangle] +/// Utility method to constructs a new GetInfoError-variant LSPS1Response +pub extern "C" fn LSPS1Response_get_info_error(a: crate::lightning_liquidity::lsps0::ser::LSPSResponseError) -> LSPS1Response { + LSPS1Response::GetInfoError(a, ) +} +#[no_mangle] +/// Utility method to constructs a new CreateOrder-variant LSPS1Response +pub extern "C" fn LSPS1Response_create_order(a: crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderResponse) -> LSPS1Response { + LSPS1Response::CreateOrder(a, ) +} +#[no_mangle] +/// Utility method to constructs a new CreateOrderError-variant LSPS1Response +pub extern "C" fn LSPS1Response_create_order_error(a: crate::lightning_liquidity::lsps0::ser::LSPSResponseError) -> LSPS1Response { + LSPS1Response::CreateOrderError(a, ) +} +#[no_mangle] +/// Utility method to constructs a new GetOrder-variant LSPS1Response +pub extern "C" fn LSPS1Response_get_order(a: crate::lightning_liquidity::lsps1::msgs::LSPS1CreateOrderResponse) -> LSPS1Response { + LSPS1Response::GetOrder(a, ) +} +#[no_mangle] +/// Utility method to constructs a new GetOrderError-variant LSPS1Response +pub extern "C" fn LSPS1Response_get_order_error(a: crate::lightning_liquidity::lsps0::ser::LSPSResponseError) -> LSPS1Response { + LSPS1Response::GetOrderError(a, ) +} +/// Get a string which allows debug introspection of a LSPS1Response object +pub extern "C" fn LSPS1Response_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1Response }).into()} +/// Checks if two LSPS1Responses contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS1Response_eq(a: &LSPS1Response, b: &LSPS1Response) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +/// An enum that captures all valid JSON-RPC messages in the bLIP-51 / LSPS1 protocol. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS1Message { + /// An LSPS1 JSON-RPC request. + Request( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + crate::lightning_liquidity::lsps1::msgs::LSPS1Request), + /// An LSPS1 JSON-RPC response. + Response( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + crate::lightning_liquidity::lsps1::msgs::LSPS1Response), +} +use lightning_liquidity::lsps1::msgs::LSPS1Message as LSPS1MessageImport; +pub(crate) type nativeLSPS1Message = LSPS1MessageImport; + +impl LSPS1Message { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS1Message { + match self { + LSPS1Message::Request (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + nativeLSPS1Message::Request ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + b_nonref.into_native(), + ) + }, + LSPS1Message::Response (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + nativeLSPS1Message::Response ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + b_nonref.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS1Message { + match self { + LSPS1Message::Request (mut a, mut b, ) => { + nativeLSPS1Message::Request ( + *unsafe { Box::from_raw(a.take_inner()) }, + b.into_native(), + ) + }, + LSPS1Message::Response (mut a, mut b, ) => { + nativeLSPS1Message::Response ( + *unsafe { Box::from_raw(a.take_inner()) }, + b.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS1MessageImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS1Message) }; + match native { + nativeLSPS1Message::Request (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + LSPS1Message::Request ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + crate::lightning_liquidity::lsps1::msgs::LSPS1Request::native_into(b_nonref), + ) + }, + nativeLSPS1Message::Response (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + LSPS1Message::Response ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + crate::lightning_liquidity::lsps1::msgs::LSPS1Response::native_into(b_nonref), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS1Message) -> Self { + match native { + nativeLSPS1Message::Request (mut a, mut b, ) => { + LSPS1Message::Request ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a), is_owned: true }, + crate::lightning_liquidity::lsps1::msgs::LSPS1Request::native_into(b), + ) + }, + nativeLSPS1Message::Response (mut a, mut b, ) => { + LSPS1Message::Response ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a), is_owned: true }, + crate::lightning_liquidity::lsps1::msgs::LSPS1Response::native_into(b), + ) + }, + } + } +} +/// Frees any resources used by the LSPS1Message +#[no_mangle] +pub extern "C" fn LSPS1Message_free(this_ptr: LSPS1Message) { } +/// Creates a copy of the LSPS1Message +#[no_mangle] +pub extern "C" fn LSPS1Message_clone(orig: &LSPS1Message) -> LSPS1Message { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1Message_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS1Message)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS1Message_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS1Message) }; +} +#[no_mangle] +/// Utility method to constructs a new Request-variant LSPS1Message +pub extern "C" fn LSPS1Message_request(a: crate::lightning_liquidity::lsps0::ser::LSPSRequestId,b: crate::lightning_liquidity::lsps1::msgs::LSPS1Request) -> LSPS1Message { + LSPS1Message::Request(a, b, ) +} +#[no_mangle] +/// Utility method to constructs a new Response-variant LSPS1Message +pub extern "C" fn LSPS1Message_response(a: crate::lightning_liquidity::lsps0::ser::LSPSRequestId,b: crate::lightning_liquidity::lsps1::msgs::LSPS1Response) -> LSPS1Message { + LSPS1Message::Response(a, b, ) +} +/// Get a string which allows debug introspection of a LSPS1Message object +pub extern "C" fn LSPS1Message_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps1::msgs::LSPS1Message }).into()} +/// Checks if two LSPS1Messages contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS1Message_eq(a: &LSPS1Message, b: &LSPS1Message) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps2/client.rs b/lightning-c-bindings/src/lightning_liquidity/lsps2/client.rs new file mode 100644 index 00000000..b0c9ace0 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps2/client.rs @@ -0,0 +1,224 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Contains the main bLIP-52 / LSPS2 client object, [`LSPS2ClientHandler`]. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning_liquidity::lsps2::client::LSPS2ClientConfig as nativeLSPS2ClientConfigImport; +pub(crate) type nativeLSPS2ClientConfig = nativeLSPS2ClientConfigImport; + +/// Client-side configuration options for JIT channels. +#[must_use] +#[repr(C)] +pub struct LSPS2ClientConfig { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS2ClientConfig, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS2ClientConfig { + type Target = nativeLSPS2ClientConfig; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS2ClientConfig { } +unsafe impl core::marker::Sync for LSPS2ClientConfig { } +impl Drop for LSPS2ClientConfig { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS2ClientConfig>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS2ClientConfig, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS2ClientConfig_free(this_obj: LSPS2ClientConfig) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2ClientConfig_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS2ClientConfig) }; +} +#[allow(unused)] +impl LSPS2ClientConfig { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS2ClientConfig { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS2ClientConfig { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS2ClientConfig { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Constructs a new LSPS2ClientConfig given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2ClientConfig_new() -> LSPS2ClientConfig { + LSPS2ClientConfig { inner: ObjOps::heap_alloc(nativeLSPS2ClientConfig { + }), is_owned: true } +} +impl Clone for LSPS2ClientConfig { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS2ClientConfig>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2ClientConfig_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS2ClientConfig)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS2ClientConfig +pub extern "C" fn LSPS2ClientConfig_clone(orig: &LSPS2ClientConfig) -> LSPS2ClientConfig { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS2ClientConfig object +pub extern "C" fn LSPS2ClientConfig_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::client::LSPS2ClientConfig }).into()} + +use lightning_liquidity::lsps2::client::LSPS2ClientHandler as nativeLSPS2ClientHandlerImport; +pub(crate) type nativeLSPS2ClientHandler = nativeLSPS2ClientHandlerImport; + +/// The main object allowing to send and receive bLIP-52 / LSPS2 messages. +/// +/// Note that currently only the 'client-trusts-LSP' trust model is supported, i.e., we don't +/// provide any additional API guidance to allow withholding the preimage until the channel is +/// opened. Please refer to the [`bLIP-52 / LSPS2 specification`] for more information. +/// +/// [`bLIP-52 / LSPS2 specification`]: https://github.com/lightning/blips/blob/master/blip-0052.md#trust-models +#[must_use] +#[repr(C)] +pub struct LSPS2ClientHandler { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS2ClientHandler, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS2ClientHandler { + type Target = nativeLSPS2ClientHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS2ClientHandler { } +unsafe impl core::marker::Sync for LSPS2ClientHandler { } +impl Drop for LSPS2ClientHandler { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS2ClientHandler>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS2ClientHandler, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS2ClientHandler_free(this_obj: LSPS2ClientHandler) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2ClientHandler_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS2ClientHandler) }; +} +#[allow(unused)] +impl LSPS2ClientHandler { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS2ClientHandler { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS2ClientHandler { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS2ClientHandler { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Request the channel opening parameters from the LSP. +/// +/// This initiates the JIT-channel flow that, at the end of it, will have the LSP +/// open a channel with sufficient inbound liquidity to be able to receive the payment. +/// +/// The user will receive the LSP's response via an [`OpeningParametersReady`] event. +/// +/// `counterparty_node_id` is the `node_id` of the LSP you would like to use. +/// +/// `token` is an optional `String` that will be provided to the LSP. +/// It can be used by the LSP as an API key, coupon code, or some other way to identify a user. +/// +/// Returns the used [`LSPSRequestId`], which will be returned via [`OpeningParametersReady`]. +/// +/// [`OpeningParametersReady`]: crate::lsps2::event::LSPS2ClientEvent::OpeningParametersReady +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2ClientHandler_request_opening_params(this_arg: &crate::lightning_liquidity::lsps2::client::LSPS2ClientHandler, mut counterparty_node_id: crate::c_types::PublicKey, mut token: crate::c_types::derived::COption_StrZ) -> crate::lightning_liquidity::lsps0::ser::LSPSRequestId { + let mut local_token = { /*token*/ let token_opt = token; if token_opt.is_none() { None } else { Some({ { { token_opt.take() }.into_string() }})} }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.request_opening_params(counterparty_node_id.into_rust(), local_token); + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Confirms a set of chosen channel opening parameters to use for the JIT channel and +/// requests the necessary invoice generation parameters from the LSP. +/// +/// Should be called in response to receiving a [`OpeningParametersReady`] event. +/// +/// The user will receive the LSP's response via an [`InvoiceParametersReady`] event. +/// +/// If `payment_size_msat` is [`Option::Some`] then the invoice will be for a fixed amount +/// and MPP can be used to pay it. +/// +/// If `payment_size_msat` is [`Option::None`] then the invoice can be for an arbitrary amount +/// but MPP can no longer be used to pay it. +/// +/// The client agrees to paying an opening fee equal to +/// `max(min_fee_msat, proportional*(payment_size_msat/1_000_000))`. +/// +/// [`OpeningParametersReady`]: crate::lsps2::event::LSPS2ClientEvent::OpeningParametersReady +/// [`InvoiceParametersReady`]: crate::lsps2::event::LSPS2ClientEvent::InvoiceParametersReady +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2ClientHandler_select_opening_params(this_arg: &crate::lightning_liquidity::lsps2::client::LSPS2ClientHandler, mut counterparty_node_id: crate::c_types::PublicKey, mut payment_size_msat: crate::c_types::derived::COption_u64Z, mut opening_fee_params: crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams) -> crate::c_types::derived::CResult_LSPSRequestIdAPIErrorZ { + let mut local_payment_size_msat = if payment_size_msat.is_some() { Some( { payment_size_msat.take() }) } else { None }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.select_opening_params(counterparty_node_id.into_rust(), local_payment_size_msat, *unsafe { Box::from_raw(opening_fee_params.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps2/event.rs b/lightning-c-bindings/src/lightning_liquidity/lsps2/event.rs new file mode 100644 index 00000000..1f15be7f --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps2/event.rs @@ -0,0 +1,502 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Contains bLIP-52 / LSPS2 event types + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// An event which an LSPS2 client should take some action in response to. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS2ClientEvent { + /// Information from the LSP about their current fee rates and channel parameters. + /// + /// You must call [`LSPS2ClientHandler::select_opening_params`] with the fee parameter + /// you want to use if you wish to proceed opening a channel. + /// + /// [`LSPS2ClientHandler::select_opening_params`]: crate::lsps2::client::LSPS2ClientHandler::select_opening_params + OpeningParametersReady { + /// The identifier of the issued bLIP-52 / LSPS2 `get_info` request, as returned by + /// [`LSPS2ClientHandler::request_opening_params`] + /// + /// This can be used to track which request this event corresponds to. + /// + /// [`LSPS2ClientHandler::request_opening_params`]: crate::lsps2::client::LSPS2ClientHandler::request_opening_params + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + /// The node id of the LSP that provided this response. + counterparty_node_id: crate::c_types::PublicKey, + /// The menu of fee parameters the LSP is offering at this time. + /// You must select one of these if you wish to proceed. + opening_fee_params_menu: crate::c_types::derived::CVec_LSPS2OpeningFeeParamsZ, + }, + /// Provides the necessary information to generate a payable invoice that then may be given to + /// the payer. + /// + /// When the invoice is paid, the LSP will open a channel with the previously agreed upon + /// parameters to you. + InvoiceParametersReady { + /// The identifier of the issued bLIP-52 / LSPS2 `buy` request, as returned by + /// [`LSPS2ClientHandler::select_opening_params`]. + /// + /// This can be used to track which request this event corresponds to. + /// + /// [`LSPS2ClientHandler::select_opening_params`]: crate::lsps2::client::LSPS2ClientHandler::select_opening_params + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + /// The node id of the LSP. + counterparty_node_id: crate::c_types::PublicKey, + /// The intercept short channel id to use in the route hint. + intercept_scid: u64, + /// The `cltv_expiry_delta` to use in the route hint. + cltv_expiry_delta: u32, + /// The initial payment size you specified. + payment_size_msat: crate::c_types::derived::COption_u64Z, + }, +} +use lightning_liquidity::lsps2::event::LSPS2ClientEvent as LSPS2ClientEventImport; +pub(crate) type nativeLSPS2ClientEvent = LSPS2ClientEventImport; + +impl LSPS2ClientEvent { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS2ClientEvent { + match self { + LSPS2ClientEvent::OpeningParametersReady {ref request_id, ref counterparty_node_id, ref opening_fee_params_menu, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut opening_fee_params_menu_nonref = Clone::clone(opening_fee_params_menu); + let mut local_opening_fee_params_menu_nonref = Vec::new(); for mut item in opening_fee_params_menu_nonref.into_rust().drain(..) { local_opening_fee_params_menu_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + nativeLSPS2ClientEvent::OpeningParametersReady { + request_id: *unsafe { Box::from_raw(request_id_nonref.take_inner()) }, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + opening_fee_params_menu: local_opening_fee_params_menu_nonref, + } + }, + LSPS2ClientEvent::InvoiceParametersReady {ref request_id, ref counterparty_node_id, ref intercept_scid, ref cltv_expiry_delta, ref payment_size_msat, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut intercept_scid_nonref = Clone::clone(intercept_scid); + let mut cltv_expiry_delta_nonref = Clone::clone(cltv_expiry_delta); + let mut payment_size_msat_nonref = Clone::clone(payment_size_msat); + let mut local_payment_size_msat_nonref = if payment_size_msat_nonref.is_some() { Some( { payment_size_msat_nonref.take() }) } else { None }; + nativeLSPS2ClientEvent::InvoiceParametersReady { + request_id: *unsafe { Box::from_raw(request_id_nonref.take_inner()) }, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + intercept_scid: intercept_scid_nonref, + cltv_expiry_delta: cltv_expiry_delta_nonref, + payment_size_msat: local_payment_size_msat_nonref, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS2ClientEvent { + match self { + LSPS2ClientEvent::OpeningParametersReady {mut request_id, mut counterparty_node_id, mut opening_fee_params_menu, } => { + let mut local_opening_fee_params_menu = Vec::new(); for mut item in opening_fee_params_menu.into_rust().drain(..) { local_opening_fee_params_menu.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + nativeLSPS2ClientEvent::OpeningParametersReady { + request_id: *unsafe { Box::from_raw(request_id.take_inner()) }, + counterparty_node_id: counterparty_node_id.into_rust(), + opening_fee_params_menu: local_opening_fee_params_menu, + } + }, + LSPS2ClientEvent::InvoiceParametersReady {mut request_id, mut counterparty_node_id, mut intercept_scid, mut cltv_expiry_delta, mut payment_size_msat, } => { + let mut local_payment_size_msat = if payment_size_msat.is_some() { Some( { payment_size_msat.take() }) } else { None }; + nativeLSPS2ClientEvent::InvoiceParametersReady { + request_id: *unsafe { Box::from_raw(request_id.take_inner()) }, + counterparty_node_id: counterparty_node_id.into_rust(), + intercept_scid: intercept_scid, + cltv_expiry_delta: cltv_expiry_delta, + payment_size_msat: local_payment_size_msat, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS2ClientEventImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS2ClientEvent) }; + match native { + nativeLSPS2ClientEvent::OpeningParametersReady {ref request_id, ref counterparty_node_id, ref opening_fee_params_menu, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut opening_fee_params_menu_nonref = Clone::clone(opening_fee_params_menu); + let mut local_opening_fee_params_menu_nonref = Vec::new(); for mut item in opening_fee_params_menu_nonref.drain(..) { local_opening_fee_params_menu_nonref.push( { crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + LSPS2ClientEvent::OpeningParametersReady { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id_nonref), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + opening_fee_params_menu: local_opening_fee_params_menu_nonref.into(), + } + }, + nativeLSPS2ClientEvent::InvoiceParametersReady {ref request_id, ref counterparty_node_id, ref intercept_scid, ref cltv_expiry_delta, ref payment_size_msat, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut intercept_scid_nonref = Clone::clone(intercept_scid); + let mut cltv_expiry_delta_nonref = Clone::clone(cltv_expiry_delta); + let mut payment_size_msat_nonref = Clone::clone(payment_size_msat); + let mut local_payment_size_msat_nonref = if payment_size_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { payment_size_msat_nonref.unwrap() }) }; + LSPS2ClientEvent::InvoiceParametersReady { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id_nonref), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + intercept_scid: intercept_scid_nonref, + cltv_expiry_delta: cltv_expiry_delta_nonref, + payment_size_msat: local_payment_size_msat_nonref, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS2ClientEvent) -> Self { + match native { + nativeLSPS2ClientEvent::OpeningParametersReady {mut request_id, mut counterparty_node_id, mut opening_fee_params_menu, } => { + let mut local_opening_fee_params_menu = Vec::new(); for mut item in opening_fee_params_menu.drain(..) { local_opening_fee_params_menu.push( { crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + LSPS2ClientEvent::OpeningParametersReady { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + opening_fee_params_menu: local_opening_fee_params_menu.into(), + } + }, + nativeLSPS2ClientEvent::InvoiceParametersReady {mut request_id, mut counterparty_node_id, mut intercept_scid, mut cltv_expiry_delta, mut payment_size_msat, } => { + let mut local_payment_size_msat = if payment_size_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { payment_size_msat.unwrap() }) }; + LSPS2ClientEvent::InvoiceParametersReady { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + intercept_scid: intercept_scid, + cltv_expiry_delta: cltv_expiry_delta, + payment_size_msat: local_payment_size_msat, + } + }, + } + } +} +/// Frees any resources used by the LSPS2ClientEvent +#[no_mangle] +pub extern "C" fn LSPS2ClientEvent_free(this_ptr: LSPS2ClientEvent) { } +/// Creates a copy of the LSPS2ClientEvent +#[no_mangle] +pub extern "C" fn LSPS2ClientEvent_clone(orig: &LSPS2ClientEvent) -> LSPS2ClientEvent { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2ClientEvent_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS2ClientEvent)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2ClientEvent_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS2ClientEvent) }; +} +#[no_mangle] +/// Utility method to constructs a new OpeningParametersReady-variant LSPS2ClientEvent +pub extern "C" fn LSPS2ClientEvent_opening_parameters_ready(request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, counterparty_node_id: crate::c_types::PublicKey, opening_fee_params_menu: crate::c_types::derived::CVec_LSPS2OpeningFeeParamsZ) -> LSPS2ClientEvent { + LSPS2ClientEvent::OpeningParametersReady { + request_id, + counterparty_node_id, + opening_fee_params_menu, + } +} +#[no_mangle] +/// Utility method to constructs a new InvoiceParametersReady-variant LSPS2ClientEvent +pub extern "C" fn LSPS2ClientEvent_invoice_parameters_ready(request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, counterparty_node_id: crate::c_types::PublicKey, intercept_scid: u64, cltv_expiry_delta: u32, payment_size_msat: crate::c_types::derived::COption_u64Z) -> LSPS2ClientEvent { + LSPS2ClientEvent::InvoiceParametersReady { + request_id, + counterparty_node_id, + intercept_scid, + cltv_expiry_delta, + payment_size_msat, + } +} +/// Get a string which allows debug introspection of a LSPS2ClientEvent object +pub extern "C" fn LSPS2ClientEvent_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::event::LSPS2ClientEvent }).into()} +/// Checks if two LSPS2ClientEvents contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS2ClientEvent_eq(a: &LSPS2ClientEvent, b: &LSPS2ClientEvent) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +/// An event which an bLIP-52 / LSPS2 server should take some action in response to. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS2ServiceEvent { + /// A request from a client for information about JIT Channel parameters. + /// + /// You must calculate the parameters for this client and pass them to + /// [`LSPS2ServiceHandler::opening_fee_params_generated`]. + /// + /// If an unrecognized or stale token is provided you can use + /// `[LSPS2ServiceHandler::invalid_token_provided`] to error the request. + /// + /// [`LSPS2ServiceHandler::opening_fee_params_generated`]: crate::lsps2::service::LSPS2ServiceHandler::opening_fee_params_generated + /// [`LSPS2ServiceHandler::invalid_token_provided`]: crate::lsps2::service::LSPS2ServiceHandler::invalid_token_provided + GetInfo { + /// An identifier that must be passed to [`LSPS2ServiceHandler::opening_fee_params_generated`]. + /// + /// [`LSPS2ServiceHandler::opening_fee_params_generated`]: crate::lsps2::service::LSPS2ServiceHandler::opening_fee_params_generated + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + /// The node id of the client making the information request. + counterparty_node_id: crate::c_types::PublicKey, + /// An optional token that can be used as an API key, coupon code, etc. + token: crate::c_types::derived::COption_StrZ, + }, + /// A client has selected a opening fee parameter to use and would like to + /// purchase a channel with an optional initial payment size. + /// + /// If `payment_size_msat` is [`Option::Some`] then the payer is allowed to use MPP. + /// If `payment_size_msat` is [`Option::None`] then the payer cannot use MPP. + /// + /// You must generate an intercept scid and `cltv_expiry_delta` for them to use + /// and call [`LSPS2ServiceHandler::invoice_parameters_generated`]. + /// + /// [`LSPS2ServiceHandler::invoice_parameters_generated`]: crate::lsps2::service::LSPS2ServiceHandler::invoice_parameters_generated + BuyRequest { + /// An identifier that must be passed into [`LSPS2ServiceHandler::invoice_parameters_generated`]. + /// + /// [`LSPS2ServiceHandler::invoice_parameters_generated`]: crate::lsps2::service::LSPS2ServiceHandler::invoice_parameters_generated + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + /// The client node id that is making this request. + counterparty_node_id: crate::c_types::PublicKey, + /// The channel parameters they have selected. + opening_fee_params: crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams, + /// The size of the initial payment they would like to receive. + payment_size_msat: crate::c_types::derived::COption_u64Z, + }, + /// You should open a channel using [`ChannelManager::create_channel`]. + /// + /// [`ChannelManager::create_channel`]: lightning::ln::channelmanager::ChannelManager::create_channel + OpenChannel { + /// The node to open channel with. + their_network_key: crate::c_types::PublicKey, + /// The amount to forward after fees. + amt_to_forward_msat: u64, + /// The fee earned for opening the channel. + opening_fee_msat: u64, + /// A user specified id used to track channel open. + user_channel_id: crate::c_types::U128, + /// The intercept short channel id to use in the route hint. + intercept_scid: u64, + }, +} +use lightning_liquidity::lsps2::event::LSPS2ServiceEvent as LSPS2ServiceEventImport; +pub(crate) type nativeLSPS2ServiceEvent = LSPS2ServiceEventImport; + +impl LSPS2ServiceEvent { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS2ServiceEvent { + match self { + LSPS2ServiceEvent::GetInfo {ref request_id, ref counterparty_node_id, ref token, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut token_nonref = Clone::clone(token); + let mut local_token_nonref = { /*token_nonref*/ let token_nonref_opt = token_nonref; if token_nonref_opt.is_none() { None } else { Some({ { { token_nonref_opt.take() }.into_string() }})} }; + nativeLSPS2ServiceEvent::GetInfo { + request_id: *unsafe { Box::from_raw(request_id_nonref.take_inner()) }, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + token: local_token_nonref, + } + }, + LSPS2ServiceEvent::BuyRequest {ref request_id, ref counterparty_node_id, ref opening_fee_params, ref payment_size_msat, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut opening_fee_params_nonref = Clone::clone(opening_fee_params); + let mut payment_size_msat_nonref = Clone::clone(payment_size_msat); + let mut local_payment_size_msat_nonref = if payment_size_msat_nonref.is_some() { Some( { payment_size_msat_nonref.take() }) } else { None }; + nativeLSPS2ServiceEvent::BuyRequest { + request_id: *unsafe { Box::from_raw(request_id_nonref.take_inner()) }, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + opening_fee_params: *unsafe { Box::from_raw(opening_fee_params_nonref.take_inner()) }, + payment_size_msat: local_payment_size_msat_nonref, + } + }, + LSPS2ServiceEvent::OpenChannel {ref their_network_key, ref amt_to_forward_msat, ref opening_fee_msat, ref user_channel_id, ref intercept_scid, } => { + let mut their_network_key_nonref = Clone::clone(their_network_key); + let mut amt_to_forward_msat_nonref = Clone::clone(amt_to_forward_msat); + let mut opening_fee_msat_nonref = Clone::clone(opening_fee_msat); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut intercept_scid_nonref = Clone::clone(intercept_scid); + nativeLSPS2ServiceEvent::OpenChannel { + their_network_key: their_network_key_nonref.into_rust(), + amt_to_forward_msat: amt_to_forward_msat_nonref, + opening_fee_msat: opening_fee_msat_nonref, + user_channel_id: user_channel_id_nonref.into(), + intercept_scid: intercept_scid_nonref, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS2ServiceEvent { + match self { + LSPS2ServiceEvent::GetInfo {mut request_id, mut counterparty_node_id, mut token, } => { + let mut local_token = { /*token*/ let token_opt = token; if token_opt.is_none() { None } else { Some({ { { token_opt.take() }.into_string() }})} }; + nativeLSPS2ServiceEvent::GetInfo { + request_id: *unsafe { Box::from_raw(request_id.take_inner()) }, + counterparty_node_id: counterparty_node_id.into_rust(), + token: local_token, + } + }, + LSPS2ServiceEvent::BuyRequest {mut request_id, mut counterparty_node_id, mut opening_fee_params, mut payment_size_msat, } => { + let mut local_payment_size_msat = if payment_size_msat.is_some() { Some( { payment_size_msat.take() }) } else { None }; + nativeLSPS2ServiceEvent::BuyRequest { + request_id: *unsafe { Box::from_raw(request_id.take_inner()) }, + counterparty_node_id: counterparty_node_id.into_rust(), + opening_fee_params: *unsafe { Box::from_raw(opening_fee_params.take_inner()) }, + payment_size_msat: local_payment_size_msat, + } + }, + LSPS2ServiceEvent::OpenChannel {mut their_network_key, mut amt_to_forward_msat, mut opening_fee_msat, mut user_channel_id, mut intercept_scid, } => { + nativeLSPS2ServiceEvent::OpenChannel { + their_network_key: their_network_key.into_rust(), + amt_to_forward_msat: amt_to_forward_msat, + opening_fee_msat: opening_fee_msat, + user_channel_id: user_channel_id.into(), + intercept_scid: intercept_scid, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS2ServiceEventImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS2ServiceEvent) }; + match native { + nativeLSPS2ServiceEvent::GetInfo {ref request_id, ref counterparty_node_id, ref token, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut token_nonref = Clone::clone(token); + let mut local_token_nonref = if token_nonref.is_none() { crate::c_types::derived::COption_StrZ::None } else { crate::c_types::derived::COption_StrZ::Some( { token_nonref.unwrap().into() }) }; + LSPS2ServiceEvent::GetInfo { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id_nonref), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + token: local_token_nonref, + } + }, + nativeLSPS2ServiceEvent::BuyRequest {ref request_id, ref counterparty_node_id, ref opening_fee_params, ref payment_size_msat, } => { + let mut request_id_nonref = Clone::clone(request_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut opening_fee_params_nonref = Clone::clone(opening_fee_params); + let mut payment_size_msat_nonref = Clone::clone(payment_size_msat); + let mut local_payment_size_msat_nonref = if payment_size_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { payment_size_msat_nonref.unwrap() }) }; + LSPS2ServiceEvent::BuyRequest { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id_nonref), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + opening_fee_params: crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams { inner: ObjOps::heap_alloc(opening_fee_params_nonref), is_owned: true }, + payment_size_msat: local_payment_size_msat_nonref, + } + }, + nativeLSPS2ServiceEvent::OpenChannel {ref their_network_key, ref amt_to_forward_msat, ref opening_fee_msat, ref user_channel_id, ref intercept_scid, } => { + let mut their_network_key_nonref = Clone::clone(their_network_key); + let mut amt_to_forward_msat_nonref = Clone::clone(amt_to_forward_msat); + let mut opening_fee_msat_nonref = Clone::clone(opening_fee_msat); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut intercept_scid_nonref = Clone::clone(intercept_scid); + LSPS2ServiceEvent::OpenChannel { + their_network_key: crate::c_types::PublicKey::from_rust(&their_network_key_nonref), + amt_to_forward_msat: amt_to_forward_msat_nonref, + opening_fee_msat: opening_fee_msat_nonref, + user_channel_id: user_channel_id_nonref.into(), + intercept_scid: intercept_scid_nonref, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS2ServiceEvent) -> Self { + match native { + nativeLSPS2ServiceEvent::GetInfo {mut request_id, mut counterparty_node_id, mut token, } => { + let mut local_token = if token.is_none() { crate::c_types::derived::COption_StrZ::None } else { crate::c_types::derived::COption_StrZ::Some( { token.unwrap().into() }) }; + LSPS2ServiceEvent::GetInfo { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + token: local_token, + } + }, + nativeLSPS2ServiceEvent::BuyRequest {mut request_id, mut counterparty_node_id, mut opening_fee_params, mut payment_size_msat, } => { + let mut local_payment_size_msat = if payment_size_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { payment_size_msat.unwrap() }) }; + LSPS2ServiceEvent::BuyRequest { + request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(request_id), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + opening_fee_params: crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams { inner: ObjOps::heap_alloc(opening_fee_params), is_owned: true }, + payment_size_msat: local_payment_size_msat, + } + }, + nativeLSPS2ServiceEvent::OpenChannel {mut their_network_key, mut amt_to_forward_msat, mut opening_fee_msat, mut user_channel_id, mut intercept_scid, } => { + LSPS2ServiceEvent::OpenChannel { + their_network_key: crate::c_types::PublicKey::from_rust(&their_network_key), + amt_to_forward_msat: amt_to_forward_msat, + opening_fee_msat: opening_fee_msat, + user_channel_id: user_channel_id.into(), + intercept_scid: intercept_scid, + } + }, + } + } +} +/// Frees any resources used by the LSPS2ServiceEvent +#[no_mangle] +pub extern "C" fn LSPS2ServiceEvent_free(this_ptr: LSPS2ServiceEvent) { } +/// Creates a copy of the LSPS2ServiceEvent +#[no_mangle] +pub extern "C" fn LSPS2ServiceEvent_clone(orig: &LSPS2ServiceEvent) -> LSPS2ServiceEvent { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2ServiceEvent_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS2ServiceEvent)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2ServiceEvent_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS2ServiceEvent) }; +} +#[no_mangle] +/// Utility method to constructs a new GetInfo-variant LSPS2ServiceEvent +pub extern "C" fn LSPS2ServiceEvent_get_info(request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, counterparty_node_id: crate::c_types::PublicKey, token: crate::c_types::derived::COption_StrZ) -> LSPS2ServiceEvent { + LSPS2ServiceEvent::GetInfo { + request_id, + counterparty_node_id, + token, + } +} +#[no_mangle] +/// Utility method to constructs a new BuyRequest-variant LSPS2ServiceEvent +pub extern "C" fn LSPS2ServiceEvent_buy_request(request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, counterparty_node_id: crate::c_types::PublicKey, opening_fee_params: crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams, payment_size_msat: crate::c_types::derived::COption_u64Z) -> LSPS2ServiceEvent { + LSPS2ServiceEvent::BuyRequest { + request_id, + counterparty_node_id, + opening_fee_params, + payment_size_msat, + } +} +#[no_mangle] +/// Utility method to constructs a new OpenChannel-variant LSPS2ServiceEvent +pub extern "C" fn LSPS2ServiceEvent_open_channel(their_network_key: crate::c_types::PublicKey, amt_to_forward_msat: u64, opening_fee_msat: u64, user_channel_id: crate::c_types::U128, intercept_scid: u64) -> LSPS2ServiceEvent { + LSPS2ServiceEvent::OpenChannel { + their_network_key, + amt_to_forward_msat, + opening_fee_msat, + user_channel_id, + intercept_scid, + } +} +/// Get a string which allows debug introspection of a LSPS2ServiceEvent object +pub extern "C" fn LSPS2ServiceEvent_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::event::LSPS2ServiceEvent }).into()} +/// Checks if two LSPS2ServiceEvents contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS2ServiceEvent_eq(a: &LSPS2ServiceEvent, b: &LSPS2ServiceEvent) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps2/mod.rs b/lightning-c-bindings/src/lightning_liquidity/lsps2/mod.rs new file mode 100644 index 00000000..13cf51e9 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps2/mod.rs @@ -0,0 +1,36 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Implementation of bLIP-52 / LSPS2: JIT Channel Negotiation specification. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +pub mod client; +pub mod event; +pub mod msgs; +pub mod service; +pub mod utils; +mod payment_queue { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps2/msgs.rs b/lightning-c-bindings/src/lightning_liquidity/lsps2/msgs.rs new file mode 100644 index 00000000..d083b1f6 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps2/msgs.rs @@ -0,0 +1,1389 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Message, request, and other primitive types used to implement bLIP-52 / LSPS2. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning_liquidity::lsps2::msgs::LSPS2GetInfoRequest as nativeLSPS2GetInfoRequestImport; +pub(crate) type nativeLSPS2GetInfoRequest = nativeLSPS2GetInfoRequestImport; + +/// A request made to an LSP to learn their current channel fees and parameters. +#[must_use] +#[repr(C)] +pub struct LSPS2GetInfoRequest { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS2GetInfoRequest, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS2GetInfoRequest { + type Target = nativeLSPS2GetInfoRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS2GetInfoRequest { } +unsafe impl core::marker::Sync for LSPS2GetInfoRequest { } +impl Drop for LSPS2GetInfoRequest { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS2GetInfoRequest>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS2GetInfoRequest, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS2GetInfoRequest_free(this_obj: LSPS2GetInfoRequest) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2GetInfoRequest_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS2GetInfoRequest) }; +} +#[allow(unused)] +impl LSPS2GetInfoRequest { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS2GetInfoRequest { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS2GetInfoRequest { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS2GetInfoRequest { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// An optional token to provide to the LSP. +#[no_mangle] +pub extern "C" fn LSPS2GetInfoRequest_get_token(this_ptr: &LSPS2GetInfoRequest) -> crate::c_types::derived::COption_StrZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().token; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_StrZ::None } else { crate::c_types::derived::COption_StrZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into() }) }; + local_inner_val +} +/// An optional token to provide to the LSP. +#[no_mangle] +pub extern "C" fn LSPS2GetInfoRequest_set_token(this_ptr: &mut LSPS2GetInfoRequest, mut val: crate::c_types::derived::COption_StrZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_string() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.token = local_val; +} +/// Constructs a new LSPS2GetInfoRequest given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2GetInfoRequest_new(mut token_arg: crate::c_types::derived::COption_StrZ) -> LSPS2GetInfoRequest { + let mut local_token_arg = { /*token_arg*/ let token_arg_opt = token_arg; if token_arg_opt.is_none() { None } else { Some({ { { token_arg_opt.take() }.into_string() }})} }; + LSPS2GetInfoRequest { inner: ObjOps::heap_alloc(nativeLSPS2GetInfoRequest { + token: local_token_arg, + }), is_owned: true } +} +impl Clone for LSPS2GetInfoRequest { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS2GetInfoRequest>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2GetInfoRequest_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS2GetInfoRequest)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS2GetInfoRequest +pub extern "C" fn LSPS2GetInfoRequest_clone(orig: &LSPS2GetInfoRequest) -> LSPS2GetInfoRequest { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS2GetInfoRequest object +pub extern "C" fn LSPS2GetInfoRequest_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::msgs::LSPS2GetInfoRequest }).into()} +/// Checks if two LSPS2GetInfoRequests contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS2GetInfoRequest_eq(a: &LSPS2GetInfoRequest, b: &LSPS2GetInfoRequest) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps2::msgs::LSPS2RawOpeningFeeParams as nativeLSPS2RawOpeningFeeParamsImport; +pub(crate) type nativeLSPS2RawOpeningFeeParams = nativeLSPS2RawOpeningFeeParamsImport; + +/// Fees and parameters for a JIT Channel without the promise. +/// +/// The promise will be calculated automatically for the LSP and this type converted +/// into an [`LSPS2OpeningFeeParams`] for transit over the wire. +#[must_use] +#[repr(C)] +pub struct LSPS2RawOpeningFeeParams { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS2RawOpeningFeeParams, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS2RawOpeningFeeParams { + type Target = nativeLSPS2RawOpeningFeeParams; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS2RawOpeningFeeParams { } +unsafe impl core::marker::Sync for LSPS2RawOpeningFeeParams { } +impl Drop for LSPS2RawOpeningFeeParams { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS2RawOpeningFeeParams>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS2RawOpeningFeeParams, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_free(this_obj: LSPS2RawOpeningFeeParams) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2RawOpeningFeeParams_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS2RawOpeningFeeParams) }; +} +#[allow(unused)] +impl LSPS2RawOpeningFeeParams { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS2RawOpeningFeeParams { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS2RawOpeningFeeParams { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS2RawOpeningFeeParams { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The minimum fee required for the channel open. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_get_min_fee_msat(this_ptr: &LSPS2RawOpeningFeeParams) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_msat; + *inner_val +} +/// The minimum fee required for the channel open. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_set_min_fee_msat(this_ptr: &mut LSPS2RawOpeningFeeParams, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_msat = val; +} +/// A fee proportional to the size of the initial payment. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_get_proportional(this_ptr: &LSPS2RawOpeningFeeParams) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().proportional; + *inner_val +} +/// A fee proportional to the size of the initial payment. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_set_proportional(this_ptr: &mut LSPS2RawOpeningFeeParams, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.proportional = val; +} +/// An [`ISO8601`](https://www.iso.org/iso-8601-date-and-time-format.html) formatted date for which these params are valid. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_get_valid_until(this_ptr: &LSPS2RawOpeningFeeParams) -> crate::lightning_liquidity::lsps0::ser::LSPSDateTime { + let mut inner_val = &mut this_ptr.get_native_mut_ref().valid_until; + crate::lightning_liquidity::lsps0::ser::LSPSDateTime { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps0::ser::LSPSDateTime<>) as *mut _) }, is_owned: false } +} +/// An [`ISO8601`](https://www.iso.org/iso-8601-date-and-time-format.html) formatted date for which these params are valid. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_set_valid_until(this_ptr: &mut LSPS2RawOpeningFeeParams, mut val: crate::lightning_liquidity::lsps0::ser::LSPSDateTime) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.valid_until = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The number of blocks after confirmation that the LSP promises it will keep the channel alive without closing. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_get_min_lifetime(this_ptr: &LSPS2RawOpeningFeeParams) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_lifetime; + *inner_val +} +/// The number of blocks after confirmation that the LSP promises it will keep the channel alive without closing. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_set_min_lifetime(this_ptr: &mut LSPS2RawOpeningFeeParams, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_lifetime = val; +} +/// The maximum number of blocks that the client is allowed to set its `to_self_delay` parameter. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_get_max_client_to_self_delay(this_ptr: &LSPS2RawOpeningFeeParams) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_client_to_self_delay; + *inner_val +} +/// The maximum number of blocks that the client is allowed to set its `to_self_delay` parameter. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_set_max_client_to_self_delay(this_ptr: &mut LSPS2RawOpeningFeeParams, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_client_to_self_delay = val; +} +/// The minimum payment size that the LSP will accept when opening a channel. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_get_min_payment_size_msat(this_ptr: &LSPS2RawOpeningFeeParams) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_payment_size_msat; + *inner_val +} +/// The minimum payment size that the LSP will accept when opening a channel. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_set_min_payment_size_msat(this_ptr: &mut LSPS2RawOpeningFeeParams, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_payment_size_msat = val; +} +/// The maximum payment size that the LSP will accept when opening a channel. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_get_max_payment_size_msat(this_ptr: &LSPS2RawOpeningFeeParams) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_payment_size_msat; + *inner_val +} +/// The maximum payment size that the LSP will accept when opening a channel. +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_set_max_payment_size_msat(this_ptr: &mut LSPS2RawOpeningFeeParams, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_payment_size_msat = val; +} +/// Constructs a new LSPS2RawOpeningFeeParams given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2RawOpeningFeeParams_new(mut min_fee_msat_arg: u64, mut proportional_arg: u32, mut valid_until_arg: crate::lightning_liquidity::lsps0::ser::LSPSDateTime, mut min_lifetime_arg: u32, mut max_client_to_self_delay_arg: u32, mut min_payment_size_msat_arg: u64, mut max_payment_size_msat_arg: u64) -> LSPS2RawOpeningFeeParams { + LSPS2RawOpeningFeeParams { inner: ObjOps::heap_alloc(nativeLSPS2RawOpeningFeeParams { + min_fee_msat: min_fee_msat_arg, + proportional: proportional_arg, + valid_until: *unsafe { Box::from_raw(valid_until_arg.take_inner()) }, + min_lifetime: min_lifetime_arg, + max_client_to_self_delay: max_client_to_self_delay_arg, + min_payment_size_msat: min_payment_size_msat_arg, + max_payment_size_msat: max_payment_size_msat_arg, + }), is_owned: true } +} + +use lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams as nativeLSPS2OpeningFeeParamsImport; +pub(crate) type nativeLSPS2OpeningFeeParams = nativeLSPS2OpeningFeeParamsImport; + +/// Fees and parameters for a JIT Channel including the promise. +/// +/// The promise is an HMAC calculated using a secret known to the LSP and the rest of the fields as input. +/// It exists so the LSP can verify the authenticity of a client provided LSPS2OpeningFeeParams by recalculating +/// the promise using the secret. Once verified they can be confident it was not modified by the client. +#[must_use] +#[repr(C)] +pub struct LSPS2OpeningFeeParams { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS2OpeningFeeParams, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS2OpeningFeeParams { + type Target = nativeLSPS2OpeningFeeParams; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS2OpeningFeeParams { } +unsafe impl core::marker::Sync for LSPS2OpeningFeeParams { } +impl Drop for LSPS2OpeningFeeParams { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS2OpeningFeeParams>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS2OpeningFeeParams, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_free(this_obj: LSPS2OpeningFeeParams) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2OpeningFeeParams_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS2OpeningFeeParams) }; +} +#[allow(unused)] +impl LSPS2OpeningFeeParams { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS2OpeningFeeParams { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS2OpeningFeeParams { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS2OpeningFeeParams { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The minimum fee required for the channel open. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_get_min_fee_msat(this_ptr: &LSPS2OpeningFeeParams) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_msat; + *inner_val +} +/// The minimum fee required for the channel open. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_set_min_fee_msat(this_ptr: &mut LSPS2OpeningFeeParams, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_msat = val; +} +/// A fee proportional to the size of the initial payment. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_get_proportional(this_ptr: &LSPS2OpeningFeeParams) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().proportional; + *inner_val +} +/// A fee proportional to the size of the initial payment. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_set_proportional(this_ptr: &mut LSPS2OpeningFeeParams, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.proportional = val; +} +/// An [`ISO8601`](https://www.iso.org/iso-8601-date-and-time-format.html) formatted date for which these params are valid. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_get_valid_until(this_ptr: &LSPS2OpeningFeeParams) -> crate::lightning_liquidity::lsps0::ser::LSPSDateTime { + let mut inner_val = &mut this_ptr.get_native_mut_ref().valid_until; + crate::lightning_liquidity::lsps0::ser::LSPSDateTime { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps0::ser::LSPSDateTime<>) as *mut _) }, is_owned: false } +} +/// An [`ISO8601`](https://www.iso.org/iso-8601-date-and-time-format.html) formatted date for which these params are valid. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_set_valid_until(this_ptr: &mut LSPS2OpeningFeeParams, mut val: crate::lightning_liquidity::lsps0::ser::LSPSDateTime) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.valid_until = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The number of blocks after confirmation that the LSP promises it will keep the channel alive without closing. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_get_min_lifetime(this_ptr: &LSPS2OpeningFeeParams) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_lifetime; + *inner_val +} +/// The number of blocks after confirmation that the LSP promises it will keep the channel alive without closing. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_set_min_lifetime(this_ptr: &mut LSPS2OpeningFeeParams, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_lifetime = val; +} +/// The maximum number of blocks that the client is allowed to set its `to_self_delay` parameter. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_get_max_client_to_self_delay(this_ptr: &LSPS2OpeningFeeParams) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_client_to_self_delay; + *inner_val +} +/// The maximum number of blocks that the client is allowed to set its `to_self_delay` parameter. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_set_max_client_to_self_delay(this_ptr: &mut LSPS2OpeningFeeParams, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_client_to_self_delay = val; +} +/// The minimum payment size that the LSP will accept when opening a channel. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_get_min_payment_size_msat(this_ptr: &LSPS2OpeningFeeParams) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().min_payment_size_msat; + *inner_val +} +/// The minimum payment size that the LSP will accept when opening a channel. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_set_min_payment_size_msat(this_ptr: &mut LSPS2OpeningFeeParams, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_payment_size_msat = val; +} +/// The maximum payment size that the LSP will accept when opening a channel. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_get_max_payment_size_msat(this_ptr: &LSPS2OpeningFeeParams) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_payment_size_msat; + *inner_val +} +/// The maximum payment size that the LSP will accept when opening a channel. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_set_max_payment_size_msat(this_ptr: &mut LSPS2OpeningFeeParams, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_payment_size_msat = val; +} +/// The HMAC used to verify the authenticity of these parameters. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_get_promise(this_ptr: &LSPS2OpeningFeeParams) -> crate::c_types::Str { + let mut inner_val = &mut this_ptr.get_native_mut_ref().promise; + inner_val.as_str().into() +} +/// The HMAC used to verify the authenticity of these parameters. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_set_promise(this_ptr: &mut LSPS2OpeningFeeParams, mut val: crate::c_types::Str) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.promise = val.into_string(); +} +/// Constructs a new LSPS2OpeningFeeParams given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_new(mut min_fee_msat_arg: u64, mut proportional_arg: u32, mut valid_until_arg: crate::lightning_liquidity::lsps0::ser::LSPSDateTime, mut min_lifetime_arg: u32, mut max_client_to_self_delay_arg: u32, mut min_payment_size_msat_arg: u64, mut max_payment_size_msat_arg: u64, mut promise_arg: crate::c_types::Str) -> LSPS2OpeningFeeParams { + LSPS2OpeningFeeParams { inner: ObjOps::heap_alloc(nativeLSPS2OpeningFeeParams { + min_fee_msat: min_fee_msat_arg, + proportional: proportional_arg, + valid_until: *unsafe { Box::from_raw(valid_until_arg.take_inner()) }, + min_lifetime: min_lifetime_arg, + max_client_to_self_delay: max_client_to_self_delay_arg, + min_payment_size_msat: min_payment_size_msat_arg, + max_payment_size_msat: max_payment_size_msat_arg, + promise: promise_arg.into_string(), + }), is_owned: true } +} +impl Clone for LSPS2OpeningFeeParams { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS2OpeningFeeParams>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2OpeningFeeParams_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS2OpeningFeeParams)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS2OpeningFeeParams +pub extern "C" fn LSPS2OpeningFeeParams_clone(orig: &LSPS2OpeningFeeParams) -> LSPS2OpeningFeeParams { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS2OpeningFeeParams object +pub extern "C" fn LSPS2OpeningFeeParams_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams }).into()} +/// Checks if two LSPS2OpeningFeeParamss contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS2OpeningFeeParams_eq(a: &LSPS2OpeningFeeParams, b: &LSPS2OpeningFeeParams) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps2::msgs::LSPS2GetInfoResponse as nativeLSPS2GetInfoResponseImport; +pub(crate) type nativeLSPS2GetInfoResponse = nativeLSPS2GetInfoResponseImport; + +/// A response to a [`LSPS2GetInfoRequest`] +#[must_use] +#[repr(C)] +pub struct LSPS2GetInfoResponse { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS2GetInfoResponse, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS2GetInfoResponse { + type Target = nativeLSPS2GetInfoResponse; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS2GetInfoResponse { } +unsafe impl core::marker::Sync for LSPS2GetInfoResponse { } +impl Drop for LSPS2GetInfoResponse { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS2GetInfoResponse>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS2GetInfoResponse, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS2GetInfoResponse_free(this_obj: LSPS2GetInfoResponse) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2GetInfoResponse_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS2GetInfoResponse) }; +} +#[allow(unused)] +impl LSPS2GetInfoResponse { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS2GetInfoResponse { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS2GetInfoResponse { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS2GetInfoResponse { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// A set of opening fee parameters. +#[no_mangle] +pub extern "C" fn LSPS2GetInfoResponse_get_opening_fee_params_menu(this_ptr: &LSPS2GetInfoResponse) -> crate::c_types::derived::CVec_LSPS2OpeningFeeParamsZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().opening_fee_params_menu; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams<>) as *mut _) }, is_owned: false } }); }; + local_inner_val.into() +} +/// A set of opening fee parameters. +#[no_mangle] +pub extern "C" fn LSPS2GetInfoResponse_set_opening_fee_params_menu(this_ptr: &mut LSPS2GetInfoResponse, mut val: crate::c_types::derived::CVec_LSPS2OpeningFeeParamsZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.opening_fee_params_menu = local_val; +} +/// Constructs a new LSPS2GetInfoResponse given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2GetInfoResponse_new(mut opening_fee_params_menu_arg: crate::c_types::derived::CVec_LSPS2OpeningFeeParamsZ) -> LSPS2GetInfoResponse { + let mut local_opening_fee_params_menu_arg = Vec::new(); for mut item in opening_fee_params_menu_arg.into_rust().drain(..) { local_opening_fee_params_menu_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + LSPS2GetInfoResponse { inner: ObjOps::heap_alloc(nativeLSPS2GetInfoResponse { + opening_fee_params_menu: local_opening_fee_params_menu_arg, + }), is_owned: true } +} +impl Clone for LSPS2GetInfoResponse { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS2GetInfoResponse>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2GetInfoResponse_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS2GetInfoResponse)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS2GetInfoResponse +pub extern "C" fn LSPS2GetInfoResponse_clone(orig: &LSPS2GetInfoResponse) -> LSPS2GetInfoResponse { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS2GetInfoResponse object +pub extern "C" fn LSPS2GetInfoResponse_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::msgs::LSPS2GetInfoResponse }).into()} +/// Checks if two LSPS2GetInfoResponses contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS2GetInfoResponse_eq(a: &LSPS2GetInfoResponse, b: &LSPS2GetInfoResponse) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps2::msgs::LSPS2BuyRequest as nativeLSPS2BuyRequestImport; +pub(crate) type nativeLSPS2BuyRequest = nativeLSPS2BuyRequestImport; + +/// A request to buy a JIT channel. +#[must_use] +#[repr(C)] +pub struct LSPS2BuyRequest { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS2BuyRequest, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS2BuyRequest { + type Target = nativeLSPS2BuyRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS2BuyRequest { } +unsafe impl core::marker::Sync for LSPS2BuyRequest { } +impl Drop for LSPS2BuyRequest { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS2BuyRequest>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS2BuyRequest, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS2BuyRequest_free(this_obj: LSPS2BuyRequest) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2BuyRequest_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS2BuyRequest) }; +} +#[allow(unused)] +impl LSPS2BuyRequest { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS2BuyRequest { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS2BuyRequest { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS2BuyRequest { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The fee parameters you would like to use. +#[no_mangle] +pub extern "C" fn LSPS2BuyRequest_get_opening_fee_params(this_ptr: &LSPS2BuyRequest) -> crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams { + let mut inner_val = &mut this_ptr.get_native_mut_ref().opening_fee_params; + crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams<>) as *mut _) }, is_owned: false } +} +/// The fee parameters you would like to use. +#[no_mangle] +pub extern "C" fn LSPS2BuyRequest_set_opening_fee_params(this_ptr: &mut LSPS2BuyRequest, mut val: crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.opening_fee_params = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The size of the initial payment you expect to receive. +#[no_mangle] +pub extern "C" fn LSPS2BuyRequest_get_payment_size_msat(this_ptr: &LSPS2BuyRequest) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_size_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The size of the initial payment you expect to receive. +#[no_mangle] +pub extern "C" fn LSPS2BuyRequest_set_payment_size_msat(this_ptr: &mut LSPS2BuyRequest, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_size_msat = local_val; +} +/// Constructs a new LSPS2BuyRequest given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2BuyRequest_new(mut opening_fee_params_arg: crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams, mut payment_size_msat_arg: crate::c_types::derived::COption_u64Z) -> LSPS2BuyRequest { + let mut local_payment_size_msat_arg = if payment_size_msat_arg.is_some() { Some( { payment_size_msat_arg.take() }) } else { None }; + LSPS2BuyRequest { inner: ObjOps::heap_alloc(nativeLSPS2BuyRequest { + opening_fee_params: *unsafe { Box::from_raw(opening_fee_params_arg.take_inner()) }, + payment_size_msat: local_payment_size_msat_arg, + }), is_owned: true } +} +impl Clone for LSPS2BuyRequest { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS2BuyRequest>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2BuyRequest_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS2BuyRequest)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS2BuyRequest +pub extern "C" fn LSPS2BuyRequest_clone(orig: &LSPS2BuyRequest) -> LSPS2BuyRequest { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS2BuyRequest object +pub extern "C" fn LSPS2BuyRequest_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::msgs::LSPS2BuyRequest }).into()} +/// Checks if two LSPS2BuyRequests contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS2BuyRequest_eq(a: &LSPS2BuyRequest, b: &LSPS2BuyRequest) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_liquidity::lsps2::msgs::LSPS2InterceptScid as nativeLSPS2InterceptScidImport; +pub(crate) type nativeLSPS2InterceptScid = nativeLSPS2InterceptScidImport; + +/// A newtype that holds a `short_channel_id` in human readable format of BBBxTTTx000. +#[must_use] +#[repr(C)] +pub struct LSPS2InterceptScid { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS2InterceptScid, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS2InterceptScid { + type Target = nativeLSPS2InterceptScid; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS2InterceptScid { } +unsafe impl core::marker::Sync for LSPS2InterceptScid { } +impl Drop for LSPS2InterceptScid { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS2InterceptScid>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS2InterceptScid, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS2InterceptScid_free(this_obj: LSPS2InterceptScid) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2InterceptScid_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS2InterceptScid) }; +} +#[allow(unused)] +impl LSPS2InterceptScid { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS2InterceptScid { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS2InterceptScid { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS2InterceptScid { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for LSPS2InterceptScid { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS2InterceptScid>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2InterceptScid_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS2InterceptScid)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS2InterceptScid +pub extern "C" fn LSPS2InterceptScid_clone(orig: &LSPS2InterceptScid) -> LSPS2InterceptScid { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS2InterceptScid object +pub extern "C" fn LSPS2InterceptScid_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::msgs::LSPS2InterceptScid }).into()} +/// Checks if two LSPS2InterceptScids contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS2InterceptScid_eq(a: &LSPS2InterceptScid, b: &LSPS2InterceptScid) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Try to convert a [`LSPS2InterceptScid`] into a u64 used by LDK. +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2InterceptScid_to_scid(this_arg: &crate::lightning_liquidity::lsps2::msgs::LSPS2InterceptScid) -> crate::c_types::derived::CResult_u64NoneZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.to_scid(); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + + +use lightning_liquidity::lsps2::msgs::LSPS2BuyResponse as nativeLSPS2BuyResponseImport; +pub(crate) type nativeLSPS2BuyResponse = nativeLSPS2BuyResponseImport; + +/// A response to a [`LSPS2BuyRequest`]. +/// +/// Includes information needed to construct an invoice. +#[must_use] +#[repr(C)] +pub struct LSPS2BuyResponse { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS2BuyResponse, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS2BuyResponse { + type Target = nativeLSPS2BuyResponse; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS2BuyResponse { } +unsafe impl core::marker::Sync for LSPS2BuyResponse { } +impl Drop for LSPS2BuyResponse { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS2BuyResponse>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS2BuyResponse, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS2BuyResponse_free(this_obj: LSPS2BuyResponse) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2BuyResponse_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS2BuyResponse) }; +} +#[allow(unused)] +impl LSPS2BuyResponse { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS2BuyResponse { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS2BuyResponse { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS2BuyResponse { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The intercept short channel id used by LSP to identify need to open channel. +#[no_mangle] +pub extern "C" fn LSPS2BuyResponse_get_jit_channel_scid(this_ptr: &LSPS2BuyResponse) -> crate::lightning_liquidity::lsps2::msgs::LSPS2InterceptScid { + let mut inner_val = &mut this_ptr.get_native_mut_ref().jit_channel_scid; + crate::lightning_liquidity::lsps2::msgs::LSPS2InterceptScid { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_liquidity::lsps2::msgs::LSPS2InterceptScid<>) as *mut _) }, is_owned: false } +} +/// The intercept short channel id used by LSP to identify need to open channel. +#[no_mangle] +pub extern "C" fn LSPS2BuyResponse_set_jit_channel_scid(this_ptr: &mut LSPS2BuyResponse, mut val: crate::lightning_liquidity::lsps2::msgs::LSPS2InterceptScid) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.jit_channel_scid = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The locktime expiry delta the lsp requires. +#[no_mangle] +pub extern "C" fn LSPS2BuyResponse_get_lsp_cltv_expiry_delta(this_ptr: &LSPS2BuyResponse) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().lsp_cltv_expiry_delta; + *inner_val +} +/// The locktime expiry delta the lsp requires. +#[no_mangle] +pub extern "C" fn LSPS2BuyResponse_set_lsp_cltv_expiry_delta(this_ptr: &mut LSPS2BuyResponse, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.lsp_cltv_expiry_delta = val; +} +/// A flag that indicates who is trusting who. +#[no_mangle] +pub extern "C" fn LSPS2BuyResponse_get_client_trusts_lsp(this_ptr: &LSPS2BuyResponse) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().client_trusts_lsp; + *inner_val +} +/// A flag that indicates who is trusting who. +#[no_mangle] +pub extern "C" fn LSPS2BuyResponse_set_client_trusts_lsp(this_ptr: &mut LSPS2BuyResponse, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.client_trusts_lsp = val; +} +/// Constructs a new LSPS2BuyResponse given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2BuyResponse_new(mut jit_channel_scid_arg: crate::lightning_liquidity::lsps2::msgs::LSPS2InterceptScid, mut lsp_cltv_expiry_delta_arg: u32, mut client_trusts_lsp_arg: bool) -> LSPS2BuyResponse { + LSPS2BuyResponse { inner: ObjOps::heap_alloc(nativeLSPS2BuyResponse { + jit_channel_scid: *unsafe { Box::from_raw(jit_channel_scid_arg.take_inner()) }, + lsp_cltv_expiry_delta: lsp_cltv_expiry_delta_arg, + client_trusts_lsp: client_trusts_lsp_arg, + }), is_owned: true } +} +impl Clone for LSPS2BuyResponse { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS2BuyResponse>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2BuyResponse_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS2BuyResponse)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS2BuyResponse +pub extern "C" fn LSPS2BuyResponse_clone(orig: &LSPS2BuyResponse) -> LSPS2BuyResponse { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS2BuyResponse object +pub extern "C" fn LSPS2BuyResponse_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::msgs::LSPS2BuyResponse }).into()} +/// Checks if two LSPS2BuyResponses contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn LSPS2BuyResponse_eq(a: &LSPS2BuyResponse, b: &LSPS2BuyResponse) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// An enum that captures all the valid JSON-RPC requests in the bLIP-52 / LSPS2 protocol. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS2Request { + /// A request to learn an LSP's channel fees and parameters. + GetInfo( + crate::lightning_liquidity::lsps2::msgs::LSPS2GetInfoRequest), + /// A request to buy a JIT channel from an LSP. + Buy( + crate::lightning_liquidity::lsps2::msgs::LSPS2BuyRequest), +} +use lightning_liquidity::lsps2::msgs::LSPS2Request as LSPS2RequestImport; +pub(crate) type nativeLSPS2Request = LSPS2RequestImport; + +impl LSPS2Request { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS2Request { + match self { + LSPS2Request::GetInfo (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS2Request::GetInfo ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS2Request::Buy (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS2Request::Buy ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS2Request { + match self { + LSPS2Request::GetInfo (mut a, ) => { + nativeLSPS2Request::GetInfo ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS2Request::Buy (mut a, ) => { + nativeLSPS2Request::Buy ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS2RequestImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS2Request) }; + match native { + nativeLSPS2Request::GetInfo (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS2Request::GetInfo ( + crate::lightning_liquidity::lsps2::msgs::LSPS2GetInfoRequest { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS2Request::Buy (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS2Request::Buy ( + crate::lightning_liquidity::lsps2::msgs::LSPS2BuyRequest { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS2Request) -> Self { + match native { + nativeLSPS2Request::GetInfo (mut a, ) => { + LSPS2Request::GetInfo ( + crate::lightning_liquidity::lsps2::msgs::LSPS2GetInfoRequest { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS2Request::Buy (mut a, ) => { + LSPS2Request::Buy ( + crate::lightning_liquidity::lsps2::msgs::LSPS2BuyRequest { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the LSPS2Request +#[no_mangle] +pub extern "C" fn LSPS2Request_free(this_ptr: LSPS2Request) { } +/// Creates a copy of the LSPS2Request +#[no_mangle] +pub extern "C" fn LSPS2Request_clone(orig: &LSPS2Request) -> LSPS2Request { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2Request_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS2Request)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2Request_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS2Request) }; +} +#[no_mangle] +/// Utility method to constructs a new GetInfo-variant LSPS2Request +pub extern "C" fn LSPS2Request_get_info(a: crate::lightning_liquidity::lsps2::msgs::LSPS2GetInfoRequest) -> LSPS2Request { + LSPS2Request::GetInfo(a, ) +} +#[no_mangle] +/// Utility method to constructs a new Buy-variant LSPS2Request +pub extern "C" fn LSPS2Request_buy(a: crate::lightning_liquidity::lsps2::msgs::LSPS2BuyRequest) -> LSPS2Request { + LSPS2Request::Buy(a, ) +} +/// Get a string which allows debug introspection of a LSPS2Request object +pub extern "C" fn LSPS2Request_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::msgs::LSPS2Request }).into()} +/// Checks if two LSPS2Requests contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS2Request_eq(a: &LSPS2Request, b: &LSPS2Request) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +/// An enum that captures all the valid JSON-RPC responses in the bLIP-52 / LSPS2 protocol. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS2Response { + /// A successful response to a [`LSPS2Request::GetInfo`] request. + GetInfo( + crate::lightning_liquidity::lsps2::msgs::LSPS2GetInfoResponse), + /// An error response to a [`LSPS2Request::GetInfo`] request. + GetInfoError( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError), + /// A successful response to a [`LSPS2Request::Buy`] request. + Buy( + crate::lightning_liquidity::lsps2::msgs::LSPS2BuyResponse), + /// An error response to a [`LSPS2Request::Buy`] request. + BuyError( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError), +} +use lightning_liquidity::lsps2::msgs::LSPS2Response as LSPS2ResponseImport; +pub(crate) type nativeLSPS2Response = LSPS2ResponseImport; + +impl LSPS2Response { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS2Response { + match self { + LSPS2Response::GetInfo (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS2Response::GetInfo ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS2Response::GetInfoError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS2Response::GetInfoError ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS2Response::Buy (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS2Response::Buy ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + LSPS2Response::BuyError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeLSPS2Response::BuyError ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS2Response { + match self { + LSPS2Response::GetInfo (mut a, ) => { + nativeLSPS2Response::GetInfo ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS2Response::GetInfoError (mut a, ) => { + nativeLSPS2Response::GetInfoError ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS2Response::Buy (mut a, ) => { + nativeLSPS2Response::Buy ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + LSPS2Response::BuyError (mut a, ) => { + nativeLSPS2Response::BuyError ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS2ResponseImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS2Response) }; + match native { + nativeLSPS2Response::GetInfo (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS2Response::GetInfo ( + crate::lightning_liquidity::lsps2::msgs::LSPS2GetInfoResponse { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS2Response::GetInfoError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS2Response::GetInfoError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS2Response::Buy (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS2Response::Buy ( + crate::lightning_liquidity::lsps2::msgs::LSPS2BuyResponse { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeLSPS2Response::BuyError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + LSPS2Response::BuyError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS2Response) -> Self { + match native { + nativeLSPS2Response::GetInfo (mut a, ) => { + LSPS2Response::GetInfo ( + crate::lightning_liquidity::lsps2::msgs::LSPS2GetInfoResponse { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS2Response::GetInfoError (mut a, ) => { + LSPS2Response::GetInfoError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS2Response::Buy (mut a, ) => { + LSPS2Response::Buy ( + crate::lightning_liquidity::lsps2::msgs::LSPS2BuyResponse { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeLSPS2Response::BuyError (mut a, ) => { + LSPS2Response::BuyError ( + crate::lightning_liquidity::lsps0::ser::LSPSResponseError { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the LSPS2Response +#[no_mangle] +pub extern "C" fn LSPS2Response_free(this_ptr: LSPS2Response) { } +/// Creates a copy of the LSPS2Response +#[no_mangle] +pub extern "C" fn LSPS2Response_clone(orig: &LSPS2Response) -> LSPS2Response { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2Response_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS2Response)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2Response_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS2Response) }; +} +#[no_mangle] +/// Utility method to constructs a new GetInfo-variant LSPS2Response +pub extern "C" fn LSPS2Response_get_info(a: crate::lightning_liquidity::lsps2::msgs::LSPS2GetInfoResponse) -> LSPS2Response { + LSPS2Response::GetInfo(a, ) +} +#[no_mangle] +/// Utility method to constructs a new GetInfoError-variant LSPS2Response +pub extern "C" fn LSPS2Response_get_info_error(a: crate::lightning_liquidity::lsps0::ser::LSPSResponseError) -> LSPS2Response { + LSPS2Response::GetInfoError(a, ) +} +#[no_mangle] +/// Utility method to constructs a new Buy-variant LSPS2Response +pub extern "C" fn LSPS2Response_buy(a: crate::lightning_liquidity::lsps2::msgs::LSPS2BuyResponse) -> LSPS2Response { + LSPS2Response::Buy(a, ) +} +#[no_mangle] +/// Utility method to constructs a new BuyError-variant LSPS2Response +pub extern "C" fn LSPS2Response_buy_error(a: crate::lightning_liquidity::lsps0::ser::LSPSResponseError) -> LSPS2Response { + LSPS2Response::BuyError(a, ) +} +/// Get a string which allows debug introspection of a LSPS2Response object +pub extern "C" fn LSPS2Response_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::msgs::LSPS2Response }).into()} +/// Checks if two LSPS2Responses contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS2Response_eq(a: &LSPS2Response, b: &LSPS2Response) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +/// An enum that captures all valid JSON-RPC messages in the bLIP-52 / LSPS2 protocol. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum LSPS2Message { + /// An LSPS2 JSON-RPC request. + Request( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + crate::lightning_liquidity::lsps2::msgs::LSPS2Request), + /// An LSPS2 JSON-RPC response. + Response( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId, + crate::lightning_liquidity::lsps2::msgs::LSPS2Response), +} +use lightning_liquidity::lsps2::msgs::LSPS2Message as LSPS2MessageImport; +pub(crate) type nativeLSPS2Message = LSPS2MessageImport; + +impl LSPS2Message { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeLSPS2Message { + match self { + LSPS2Message::Request (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + nativeLSPS2Message::Request ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + b_nonref.into_native(), + ) + }, + LSPS2Message::Response (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + nativeLSPS2Message::Response ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + b_nonref.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeLSPS2Message { + match self { + LSPS2Message::Request (mut a, mut b, ) => { + nativeLSPS2Message::Request ( + *unsafe { Box::from_raw(a.take_inner()) }, + b.into_native(), + ) + }, + LSPS2Message::Response (mut a, mut b, ) => { + nativeLSPS2Message::Response ( + *unsafe { Box::from_raw(a.take_inner()) }, + b.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &LSPS2MessageImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeLSPS2Message) }; + match native { + nativeLSPS2Message::Request (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + LSPS2Message::Request ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + crate::lightning_liquidity::lsps2::msgs::LSPS2Request::native_into(b_nonref), + ) + }, + nativeLSPS2Message::Response (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + LSPS2Message::Response ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + crate::lightning_liquidity::lsps2::msgs::LSPS2Response::native_into(b_nonref), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeLSPS2Message) -> Self { + match native { + nativeLSPS2Message::Request (mut a, mut b, ) => { + LSPS2Message::Request ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a), is_owned: true }, + crate::lightning_liquidity::lsps2::msgs::LSPS2Request::native_into(b), + ) + }, + nativeLSPS2Message::Response (mut a, mut b, ) => { + LSPS2Message::Response ( + crate::lightning_liquidity::lsps0::ser::LSPSRequestId { inner: ObjOps::heap_alloc(a), is_owned: true }, + crate::lightning_liquidity::lsps2::msgs::LSPS2Response::native_into(b), + ) + }, + } + } +} +/// Frees any resources used by the LSPS2Message +#[no_mangle] +pub extern "C" fn LSPS2Message_free(this_ptr: LSPS2Message) { } +/// Creates a copy of the LSPS2Message +#[no_mangle] +pub extern "C" fn LSPS2Message_clone(orig: &LSPS2Message) -> LSPS2Message { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2Message_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const LSPS2Message)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2Message_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut LSPS2Message) }; +} +#[no_mangle] +/// Utility method to constructs a new Request-variant LSPS2Message +pub extern "C" fn LSPS2Message_request(a: crate::lightning_liquidity::lsps0::ser::LSPSRequestId,b: crate::lightning_liquidity::lsps2::msgs::LSPS2Request) -> LSPS2Message { + LSPS2Message::Request(a, b, ) +} +#[no_mangle] +/// Utility method to constructs a new Response-variant LSPS2Message +pub extern "C" fn LSPS2Message_response(a: crate::lightning_liquidity::lsps0::ser::LSPSRequestId,b: crate::lightning_liquidity::lsps2::msgs::LSPS2Response) -> LSPS2Message { + LSPS2Message::Response(a, b, ) +} +/// Get a string which allows debug introspection of a LSPS2Message object +pub extern "C" fn LSPS2Message_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::msgs::LSPS2Message }).into()} +/// Checks if two LSPS2Messages contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn LSPS2Message_eq(a: &LSPS2Message, b: &LSPS2Message) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps2/service.rs b/lightning-c-bindings/src/lightning_liquidity/lsps2/service.rs new file mode 100644 index 00000000..d752d2a7 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps2/service.rs @@ -0,0 +1,292 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Contains the main bLIP-52 / LSPS2 server-side object, [`LSPS2ServiceHandler`]. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning_liquidity::lsps2::service::LSPS2ServiceConfig as nativeLSPS2ServiceConfigImport; +pub(crate) type nativeLSPS2ServiceConfig = nativeLSPS2ServiceConfigImport; + +/// Server-side configuration options for JIT channels. +#[must_use] +#[repr(C)] +pub struct LSPS2ServiceConfig { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS2ServiceConfig, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS2ServiceConfig { + type Target = nativeLSPS2ServiceConfig; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS2ServiceConfig { } +unsafe impl core::marker::Sync for LSPS2ServiceConfig { } +impl Drop for LSPS2ServiceConfig { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS2ServiceConfig>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS2ServiceConfig, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS2ServiceConfig_free(this_obj: LSPS2ServiceConfig) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2ServiceConfig_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS2ServiceConfig) }; +} +#[allow(unused)] +impl LSPS2ServiceConfig { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS2ServiceConfig { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS2ServiceConfig { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS2ServiceConfig { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Used to calculate the promise for channel parameters supplied to clients. +/// +/// Note: If this changes then old promises given out will be considered invalid. +#[no_mangle] +pub extern "C" fn LSPS2ServiceConfig_get_promise_secret(this_ptr: &LSPS2ServiceConfig) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().promise_secret; + inner_val +} +/// Used to calculate the promise for channel parameters supplied to clients. +/// +/// Note: If this changes then old promises given out will be considered invalid. +#[no_mangle] +pub extern "C" fn LSPS2ServiceConfig_set_promise_secret(this_ptr: &mut LSPS2ServiceConfig, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.promise_secret = val.data; +} +/// Constructs a new LSPS2ServiceConfig given each field +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2ServiceConfig_new(mut promise_secret_arg: crate::c_types::ThirtyTwoBytes) -> LSPS2ServiceConfig { + LSPS2ServiceConfig { inner: ObjOps::heap_alloc(nativeLSPS2ServiceConfig { + promise_secret: promise_secret_arg.data, + }), is_owned: true } +} +impl Clone for LSPS2ServiceConfig { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeLSPS2ServiceConfig>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2ServiceConfig_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLSPS2ServiceConfig)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the LSPS2ServiceConfig +pub extern "C" fn LSPS2ServiceConfig_clone(orig: &LSPS2ServiceConfig) -> LSPS2ServiceConfig { + orig.clone() +} +/// Get a string which allows debug introspection of a LSPS2ServiceConfig object +pub extern "C" fn LSPS2ServiceConfig_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_liquidity::lsps2::service::LSPS2ServiceConfig }).into()} + +use lightning_liquidity::lsps2::service::LSPS2ServiceHandler as nativeLSPS2ServiceHandlerImport; +pub(crate) type nativeLSPS2ServiceHandler = nativeLSPS2ServiceHandlerImport; + +/// The main object allowing to send and receive bLIP-52 / LSPS2 messages. +#[must_use] +#[repr(C)] +pub struct LSPS2ServiceHandler { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeLSPS2ServiceHandler, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for LSPS2ServiceHandler { + type Target = nativeLSPS2ServiceHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LSPS2ServiceHandler { } +unsafe impl core::marker::Sync for LSPS2ServiceHandler { } +impl Drop for LSPS2ServiceHandler { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeLSPS2ServiceHandler>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the LSPS2ServiceHandler, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn LSPS2ServiceHandler_free(this_obj: LSPS2ServiceHandler) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn LSPS2ServiceHandler_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLSPS2ServiceHandler) }; +} +#[allow(unused)] +impl LSPS2ServiceHandler { + pub(crate) fn get_native_ref(&self) -> &'static nativeLSPS2ServiceHandler { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLSPS2ServiceHandler { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeLSPS2ServiceHandler { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Used by LSP to inform a client requesting a JIT Channel the token they used is invalid. +/// +/// Should be called in response to receiving a [`LSPS2ServiceEvent::GetInfo`] event. +/// +/// [`LSPS2ServiceEvent::GetInfo`]: crate::lsps2::event::LSPS2ServiceEvent::GetInfo +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2ServiceHandler_invalid_token_provided(this_arg: &crate::lightning_liquidity::lsps2::service::LSPS2ServiceHandler, mut counterparty_node_id: crate::c_types::PublicKey, mut request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invalid_token_provided(&counterparty_node_id.into_rust(), *unsafe { Box::from_raw(request_id.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + +/// Used by LSP to provide fee parameters to a client requesting a JIT Channel. +/// +/// Should be called in response to receiving a [`LSPS2ServiceEvent::GetInfo`] event. +/// +/// [`LSPS2ServiceEvent::GetInfo`]: crate::lsps2::event::LSPS2ServiceEvent::GetInfo +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2ServiceHandler_opening_fee_params_generated(this_arg: &crate::lightning_liquidity::lsps2::service::LSPS2ServiceHandler, mut counterparty_node_id: crate::c_types::PublicKey, mut request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, mut opening_fee_params_menu: crate::c_types::derived::CVec_LSPS2RawOpeningFeeParamsZ) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut local_opening_fee_params_menu = Vec::new(); for mut item in opening_fee_params_menu.into_rust().drain(..) { local_opening_fee_params_menu.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.opening_fee_params_generated(&counterparty_node_id.into_rust(), *unsafe { Box::from_raw(request_id.take_inner()) }, local_opening_fee_params_menu); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + +/// Used by LSP to provide client with the intercept scid and cltv_expiry_delta to use in their invoice. +/// +/// Should be called in response to receiving a [`LSPS2ServiceEvent::BuyRequest`] event. +/// +/// [`LSPS2ServiceEvent::BuyRequest`]: crate::lsps2::event::LSPS2ServiceEvent::BuyRequest +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2ServiceHandler_invoice_parameters_generated(this_arg: &crate::lightning_liquidity::lsps2::service::LSPS2ServiceHandler, mut counterparty_node_id: crate::c_types::PublicKey, mut request_id: crate::lightning_liquidity::lsps0::ser::LSPSRequestId, mut intercept_scid: u64, mut cltv_expiry_delta: u32, mut client_trusts_lsp: bool, mut user_channel_id: crate::c_types::U128) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_parameters_generated(&counterparty_node_id.into_rust(), *unsafe { Box::from_raw(request_id.take_inner()) }, intercept_scid, cltv_expiry_delta, client_trusts_lsp, user_channel_id.into()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + +/// Forward [`Event::HTLCIntercepted`] event parameters into this function. +/// +/// Will fail the intercepted HTLC if the intercept scid matches a payment we are expecting +/// but the payment amount is incorrect or the expiry has passed. +/// +/// Will generate a [`LSPS2ServiceEvent::OpenChannel`] event if the intercept scid matches a payment we are expected +/// and the payment amount is correct and the offer has not expired. +/// +/// Will do nothing if the intercept scid does not match any of the ones we gave out. +/// +/// [`Event::HTLCIntercepted`]: lightning::events::Event::HTLCIntercepted +/// [`LSPS2ServiceEvent::OpenChannel`]: crate::lsps2::event::LSPS2ServiceEvent::OpenChannel +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2ServiceHandler_htlc_intercepted(this_arg: &crate::lightning_liquidity::lsps2::service::LSPS2ServiceHandler, mut intercept_scid: u64, mut intercept_id: crate::c_types::ThirtyTwoBytes, mut expected_outbound_amount_msat: u64, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.htlc_intercepted(intercept_scid, ::lightning::ln::channelmanager::InterceptId(intercept_id.data), expected_outbound_amount_msat, ::lightning::types::payment::PaymentHash(payment_hash.data)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + +/// Forward [`Event::HTLCHandlingFailed`] event parameter into this function. +/// +/// Will attempt to forward the next payment in the queue if one is present. +/// Will do nothing if the intercept scid does not match any of the ones we gave out +/// or if the payment queue is empty +/// +/// [`Event::HTLCHandlingFailed`]: lightning::events::Event::HTLCHandlingFailed +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2ServiceHandler_htlc_handling_failed(this_arg: &crate::lightning_liquidity::lsps2::service::LSPS2ServiceHandler, mut failed_next_destination: crate::lightning::events::HTLCDestination) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.htlc_handling_failed(failed_next_destination.into_native()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + +/// Forward [`Event::PaymentForwarded`] event parameter into this function. +/// +/// Will register the forwarded payment as having paid the JIT channel fee, and forward any held +/// and future HTLCs for the SCID of the initial invoice. In the future, this will verify the +/// `skimmed_fee_msat` in [`Event::PaymentForwarded`]. +/// +/// Note that `next_channel_id` is required to be provided. Therefore, the corresponding +/// [`Event::PaymentForwarded`] events need to be generated and serialized by LDK versions +/// greater or equal to 0.0.107. +/// +/// [`Event::PaymentForwarded`]: lightning::events::Event::PaymentForwarded +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2ServiceHandler_payment_forwarded(this_arg: &crate::lightning_liquidity::lsps2::service::LSPS2ServiceHandler, mut next_channel_id: crate::lightning::ln::types::ChannelId) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_forwarded(*unsafe { Box::from_raw(next_channel_id.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + +/// Forward [`Event::ChannelReady`] event parameters into this function. +/// +/// Will forward the intercepted HTLC if it matches a channel +/// we need to forward a payment over otherwise it will be ignored. +/// +/// [`Event::ChannelReady`]: lightning::events::Event::ChannelReady +#[must_use] +#[no_mangle] +pub extern "C" fn LSPS2ServiceHandler_channel_ready(this_arg: &crate::lightning_liquidity::lsps2::service::LSPS2ServiceHandler, mut user_channel_id: crate::c_types::U128, channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_ready(user_channel_id.into(), channel_id.get_native_ref(), &counterparty_node_id.into_rust()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + diff --git a/lightning-c-bindings/src/lightning_liquidity/lsps2/utils.rs b/lightning-c-bindings/src/lightning_liquidity/lsps2/utils.rs new file mode 100644 index 00000000..19627b74 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/lsps2/utils.rs @@ -0,0 +1,45 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Utilities for implementing the bLIP-52 / LSPS2 standard. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// Determines if the given parameters are valid given the secret used to generate the promise. +#[no_mangle] +pub extern "C" fn is_valid_opening_fee_params(fee_params: &crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams, promise_secret: *const [u8; 32]) -> bool { + let mut ret = lightning_liquidity::lsps2::utils::is_valid_opening_fee_params(fee_params.get_native_ref(), unsafe { &*promise_secret}); + ret +} + +/// Determines if the given parameters are expired, or still valid. +#[no_mangle] +pub extern "C" fn is_expired_opening_fee_params(fee_params: &crate::lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams) -> bool { + let mut ret = lightning_liquidity::lsps2::utils::is_expired_opening_fee_params(fee_params.get_native_ref()); + ret +} + +/// Computes the opening fee given a payment size and the fee parameters. +/// +/// Returns [`Option::None`] when the computation overflows. +/// +/// See the [`specification`](https://github.com/lightning/blips/blob/master/blip-0052.md#computing-the-opening_fee) for more details. +#[no_mangle] +pub extern "C" fn compute_opening_fee(mut payment_size_msat: u64, mut opening_fee_min_fee_msat: u64, mut opening_fee_proportional: u64) -> crate::c_types::derived::COption_u64Z { + let mut ret = lightning_liquidity::lsps2::utils::compute_opening_fee(payment_size_msat, opening_fee_min_fee_msat, opening_fee_proportional); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; + local_ret +} + diff --git a/lightning-c-bindings/src/lightning_liquidity/message_queue.rs b/lightning-c-bindings/src/lightning_liquidity/message_queue.rs new file mode 100644 index 00000000..6c396786 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/message_queue.rs @@ -0,0 +1,145 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Holds types and traits used to implement message queues for [`LSPSMessage`]s. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning_liquidity::message_queue::MessageQueue as nativeMessageQueueImport; +pub(crate) type nativeMessageQueue = nativeMessageQueueImport; + +/// The default [`MessageQueue`] Implementation used by [`LiquidityManager`]. +/// +/// [`LiquidityManager`]: crate::LiquidityManager +#[must_use] +#[repr(C)] +pub struct MessageQueue { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeMessageQueue, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for MessageQueue { + type Target = nativeMessageQueue; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MessageQueue { } +unsafe impl core::marker::Sync for MessageQueue { } +impl Drop for MessageQueue { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeMessageQueue>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the MessageQueue, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn MessageQueue_free(this_obj: MessageQueue) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageQueue_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeMessageQueue) }; +} +#[allow(unused)] +impl MessageQueue { + pub(crate) fn get_native_ref(&self) -> &'static nativeMessageQueue { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeMessageQueue { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeMessageQueue { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// A callback which will be called to trigger network message processing. +/// +/// Usually, this should call [`PeerManager::process_events`]. +/// +/// [`PeerManager::process_events`]: lightning::ln::peer_handler::PeerManager::process_events +#[repr(C)] +pub struct ProcessMessagesCallback { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// The method which is called. + pub call: extern "C" fn (this_arg: *const c_void), + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for ProcessMessagesCallback {} +unsafe impl Sync for ProcessMessagesCallback {} +#[allow(unused)] +pub(crate) fn ProcessMessagesCallback_clone_fields(orig: &ProcessMessagesCallback) -> ProcessMessagesCallback { + ProcessMessagesCallback { + this_arg: orig.this_arg, + call: Clone::clone(&orig.call), + free: Clone::clone(&orig.free), + } +} + +use lightning_liquidity::message_queue::ProcessMessagesCallback as rustProcessMessagesCallback; +impl rustProcessMessagesCallback for ProcessMessagesCallback { + fn call(&self) { + (self.call)(self.this_arg) + } +} + +pub struct ProcessMessagesCallbackRef(ProcessMessagesCallback); +impl rustProcessMessagesCallback for ProcessMessagesCallbackRef { + fn call(&self) { + (self.0.call)(self.0.this_arg) + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for ProcessMessagesCallback { + type Target = ProcessMessagesCallbackRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ProcessMessagesCallbackRef) } + } +} +impl core::ops::DerefMut for ProcessMessagesCallback { + fn deref_mut(&mut self) -> &mut ProcessMessagesCallbackRef { + unsafe { &mut *(self as *mut _ as *mut ProcessMessagesCallbackRef) } + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn ProcessMessagesCallback_free(this_ptr: ProcessMessagesCallback) { } +impl Drop for ProcessMessagesCallback { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} diff --git a/lightning-c-bindings/src/lightning_liquidity/mod.rs b/lightning-c-bindings/src/lightning_liquidity/mod.rs new file mode 100644 index 00000000..35a36a85 --- /dev/null +++ b/lightning-c-bindings/src/lightning_liquidity/mod.rs @@ -0,0 +1,127 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//!lightning_liquidity +//! The goal of this crate is to provide types and primitives to integrate a spec-compliant LSP +//! with an LDK-based node. To this end, this crate provides client-side as well as service-side +//! logic to implement the LSPS specifications. +//! +//! **Note**: Service-side support is currently considered \"beta\", i.e., not fully ready for +//! production use. +//! +//! Currently the following specifications are supported: +//! - [bLIP-50 / LSPS0] defines the transport protocol with the LSP over which the other protocols communicate. +//! - [bLIP-51 / LSPS1] defines a protocol for ordering Lightning channels from an LSP. This is useful when the client needs +//! inbound Lightning liquidity for which they are willing and able to pay in bitcoin. +//! - [bLIP-52 / LSPS2] defines a protocol for generating a special invoice for which, when paid, +//! an LSP will open a \"just-in-time\" channel. This is useful for the initial on-boarding of +//! clients as the channel opening fees are deducted from the incoming payment, i.e., no funds are +//! required client-side to initiate this flow. +//! +//! To get started, you'll want to setup a [`LiquidityManager`] and configure it to be the +//! [`CustomMessageHandler`] of your LDK node. You can then for example call +//! [`LiquidityManager::lsps1_client_handler`] / [`LiquidityManager::lsps2_client_handler`], or +//! [`LiquidityManager::lsps2_service_handler`], to access the respective client-side or +//! service-side handlers. +//! +//! [`LiquidityManager`] uses an eventing system to notify the user about important updates to the +//! protocol flow. To this end, you will need to handle events emitted via one of the event +//! handling methods provided by [`LiquidityManager`], e.g., [`LiquidityManager::next_event`]. +//! +//! [bLIP-50 / LSPS0]: https://github.com/lightning/blips/blob/master/blip-0050.md +//! [bLIP-51 / LSPS1]: https://github.com/lightning/blips/blob/master/blip-0051.md +//! [bLIP-52 / LSPS2]: https://github.com/lightning/blips/blob/master/blip-0052.md +//! [`CustomMessageHandler`]: lightning::ln::peer_handler::CustomMessageHandler +//! [`LiquidityManager::next_event`]: crate::LiquidityManager::next_event + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +pub mod events; +pub mod lsps0; +pub mod lsps1; +pub mod lsps2; +pub mod message_queue; +mod prelude { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} +mod manager { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} +mod sync { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +mod fairrwlock { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} +mod ext_impl { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} +} +mod utils { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} From 397453aeb0771e06d9baf29a2b4bee3e8226ca16 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 5 Apr 2025 17:45:53 +0000 Subject: [PATCH 08/12] Use `-Zbuild-std` for EXTRA_TARGETs, enabling builds without rustup --- genbindings.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genbindings.sh b/genbindings.sh index ea8a0455..07c089d3 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -620,7 +620,7 @@ for IDX in ${!EXTRA_TARGETS[@]}; do ;; esac [ "${EXTRA_LINK_LTO[$IDX]}" != "" ] && EXTRA_RUSTFLAGS="-C linker-plugin-lto" - RUSTFLAGS="$BASE_RUSTFLAGS -C embed-bitcode=yes -C lto -C linker=${EXTRA_CCS[$IDX]} $EXTRA_RUSTFLAGS" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS -v --release --target "${EXTRA_TARGETS[$IDX]}" + RUSTC_BOOTSTRAP=1 RUSTFLAGS="$BASE_RUSTFLAGS -C embed-bitcode=yes -C lto -C linker=${EXTRA_CCS[$IDX]} $EXTRA_RUSTFLAGS" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS -v --release --target "${EXTRA_TARGETS[$IDX]}" -Zbuild-std=std,panic_abort done if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then From 4ea4b7bd35fc9c5e4736b7714f4ba67bc23691a9 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 5 Apr 2025 19:42:02 +0000 Subject: [PATCH 09/12] Compile EXTRA_TARGET C libraries with -fPIC It appears some newer toolchains require this when linking, and honestly not sure why older ones didn't, but its good practice in any case. --- genbindings.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/genbindings.sh b/genbindings.sh index 07c089d3..a1dd84d6 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -610,12 +610,12 @@ fi for IDX in ${!EXTRA_TARGETS[@]}; do EXTRA_ENV_TARGET=$(echo "${EXTRA_TARGETS[$IDX]}" | sed 's/-/_/g') - export CFLAGS_$EXTRA_ENV_TARGET="$BASE_CFLAGS" + export CFLAGS_$EXTRA_ENV_TARGET="$BASE_CFLAGS -fPIC" export CC_$EXTRA_ENV_TARGET=${EXTRA_CCS[$IDX]} EXTRA_RUSTFLAGS="" case "$EXTRA_ENV_TARGET" in "x86_64"*) - export CFLAGS_$EXTRA_ENV_TARGET="$BASE_CFLAGS -march=sandybridge -mtune=sandybridge" + export CFLAGS_$EXTRA_ENV_TARGET="$BASE_CFLAGS -march=sandybridge -mtune=sandybridge -fPIC" EXTRA_RUSTFLAGS="-C target-cpu=sandybridge" ;; esac From 1959b6bb7298648780f4ce9986276d8e74bc2d24 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 7 Apr 2025 00:11:02 +0000 Subject: [PATCH 10/12] Use REALLY_PIN_CC for Android builds as well --- genbindings.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/genbindings.sh b/genbindings.sh index a1dd84d6..66ebffc0 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -620,7 +620,13 @@ for IDX in ${!EXTRA_TARGETS[@]}; do ;; esac [ "${EXTRA_LINK_LTO[$IDX]}" != "" ] && EXTRA_RUSTFLAGS="-C linker-plugin-lto" - RUSTC_BOOTSTRAP=1 RUSTFLAGS="$BASE_RUSTFLAGS -C embed-bitcode=yes -C lto -C linker=${EXTRA_CCS[$IDX]} $EXTRA_RUSTFLAGS" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS -v --release --target "${EXTRA_TARGETS[$IDX]}" -Zbuild-std=std,panic_abort + + # At some point rustc fixed the issue which merits REALLY_PIN_CC. I'm not sure when, + # however, so we just use 1.84 as the cutoff. + [ "$RUSTC_MINOR_VERSION" -lt 84 ] && REALLY_PIN_CC + [ "$RUSTC_MINOR_VERSION" -lt 84 ] && OFFLINE_OPT="--offline" + + RUSTC_BOOTSTRAP=1 RUSTFLAGS="$BASE_RUSTFLAGS -C embed-bitcode=yes -C lto -C linker=${EXTRA_CCS[$IDX]} $EXTRA_RUSTFLAGS" CARGO_PROFILE_RELEASE_LTO=true cargo build $OFFLINE_OPT $CARGO_BUILD_ARGS -v --release --target "${EXTRA_TARGETS[$IDX]}" -Zbuild-std=std,panic_abort done if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then From 43b95856e6bfdae8069b6295ffa705447f09d545 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 7 Apr 2025 00:37:11 +0000 Subject: [PATCH 11/12] Use `llvm-ar` rather than looking for a target-specific one --- genbindings.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/genbindings.sh b/genbindings.sh index 66ebffc0..80626d7d 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -612,6 +612,8 @@ for IDX in ${!EXTRA_TARGETS[@]}; do EXTRA_ENV_TARGET=$(echo "${EXTRA_TARGETS[$IDX]}" | sed 's/-/_/g') export CFLAGS_$EXTRA_ENV_TARGET="$BASE_CFLAGS -fPIC" export CC_$EXTRA_ENV_TARGET=${EXTRA_CCS[$IDX]} + # Dunno why cc even looks for a target-specific ar, but just use LLVM + export AR_$EXTRA_ENV_TARGET=llvm-ar EXTRA_RUSTFLAGS="" case "$EXTRA_ENV_TARGET" in "x86_64"*) From 0a2c6ef642ff271d4d6f1bd4fd4bca8f7c734b1a Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 7 Apr 2025 12:44:31 +0000 Subject: [PATCH 12/12] Explicitly fetch `compiler-builtins` deps for offline builds --- deterministic-build-wrappers/compiler-builtins-dummy/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deterministic-build-wrappers/compiler-builtins-dummy/Cargo.toml b/deterministic-build-wrappers/compiler-builtins-dummy/Cargo.toml index 23113e2b..38b1e9d0 100644 --- a/deterministic-build-wrappers/compiler-builtins-dummy/Cargo.toml +++ b/deterministic-build-wrappers/compiler-builtins-dummy/Cargo.toml @@ -5,3 +5,5 @@ edition = "2021" [dependencies] compiler_builtins = "=0.1.109" +gimli = "=0.25.0" +object = "=0.26.2"