From: Matt Corallo Date: Tue, 8 Jun 2021 02:00:06 +0000 (+0000) Subject: Regenerate auto-generated bindings X-Git-Tag: v0.0.98~3^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=0d06fa1c196fad82d1c1c5a3b59fc6bd76f9cc12;p=ldk-c-bindings Regenerate auto-generated bindings --- diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index c6c97b7..8d27f34 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -164,9 +164,13 @@ typedef enum LDKCurrency { */ LDKCurrency_Regtest, /** - * Bitcoin simnet/signet + * Bitcoin simnet */ LDKCurrency_Simnet, + /** + * Bitcoin signet + */ + LDKCurrency_Signet, /** * Must be last for serialization purposes */ @@ -5377,7 +5381,8 @@ typedef enum LDKEvent_Tag { */ LDKEvent_PendingHTLCsForwardable, /** - * Used to indicate that an output was generated on-chain which you should know how to spend. + * Used to indicate that an output which you should know how to spend was confirmed on chain + * and is now spendable. * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your * counterparty spending them due to some kind of timeout. Thus, you need to store them * somewhere and spend them when you create on-chain transactions. @@ -12138,6 +12143,16 @@ void WatchedOutput_set_script_pubkey(struct LDKWatchedOutput *NONNULL_PTR this_p */ MUST_USE_RES struct LDKWatchedOutput WatchedOutput_new(struct LDKThirtyTwoBytes block_hash_arg, struct LDKOutPoint outpoint_arg, struct LDKCVec_u8Z script_pubkey_arg); +/** + * Creates a copy of the WatchedOutput + */ +struct LDKWatchedOutput WatchedOutput_clone(const struct LDKWatchedOutput *NONNULL_PTR orig); + +/** + * Checks if two WatchedOutputs contain equal inner contents. + */ +uint64_t WatchedOutput_hash(const struct LDKWatchedOutput *NONNULL_PTR o); + /** * Calls the free function if one is set */ @@ -12946,6 +12961,11 @@ void ChainParameters_set_best_block(struct LDKChainParameters *NONNULL_PTR this_ */ MUST_USE_RES struct LDKChainParameters ChainParameters_new(enum LDKNetwork network_arg, struct LDKBestBlock best_block_arg); +/** + * Creates a copy of the ChainParameters + */ +struct LDKChainParameters ChainParameters_clone(const struct LDKChainParameters *NONNULL_PTR orig); + /** * Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL. */ @@ -16383,9 +16403,15 @@ struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); /** - * panics if htlc.transaction_output_index.is_none()! + * 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). */ -struct LDKTransaction build_htlc_transaction(const uint8_t (*prev_hash)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key); +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, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key); /** * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. @@ -16760,7 +16786,12 @@ MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const st MUST_USE_RES struct LDKCResult_CVec_SignatureZNoneZ 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); /** - * Get the transaction number obscure factor + * 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. */ uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); diff --git a/lightning-c-bindings/src/lightning/chain/mod.rs b/lightning-c-bindings/src/lightning/chain/mod.rs index 63d70e3..d2704fa 100644 --- a/lightning-c-bindings/src/lightning/chain/mod.rs +++ b/lightning-c-bindings/src/lightning/chain/mod.rs @@ -578,3 +578,32 @@ pub extern "C" fn WatchedOutput_new(mut block_hash_arg: crate::c_types::ThirtyTw script_pubkey: ::bitcoin::blockdata::script::Script::from(script_pubkey_arg.into_rust()), })), is_owned: true } } +impl Clone for WatchedOutput { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeWatchedOutput>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*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 WatchedOutput_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWatchedOutput)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the WatchedOutput +pub extern "C" fn WatchedOutput_clone(orig: &WatchedOutput) -> WatchedOutput { + orig.clone() +} +/// Checks if two WatchedOutputs contain equal inner contents. +#[no_mangle] +pub extern "C" fn WatchedOutput_hash(o: &WatchedOutput) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + std::hash::Hash::hash(unsafe { &*o.inner }, &mut hasher); + std::hash::Hasher::finish(&hasher) +} diff --git a/lightning-c-bindings/src/lightning/ln/chan_utils.rs b/lightning-c-bindings/src/lightning/ln/chan_utils.rs index 529beac..90dd91f 100644 --- a/lightning-c-bindings/src/lightning/ln/chan_utils.rs +++ b/lightning-c-bindings/src/lightning/ln/chan_utils.rs @@ -617,10 +617,16 @@ pub extern "C" fn make_funding_redeemscript(mut broadcaster: crate::c_types::Pub ret.into_bytes().into() } -/// panics if htlc.transaction_output_index.is_none()! +/// 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). #[no_mangle] -pub extern "C" fn build_htlc_transaction(prev_hash: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey, mut revocation_key: crate::c_types::PublicKey) -> crate::c_types::Transaction { - let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*prev_hash }[..]).unwrap(), feerate_per_kw, contest_delay, unsafe { &*htlc.inner }, &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust()); +pub extern "C" fn build_htlc_transaction(commitment_txid: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey, mut revocation_key: crate::c_types::PublicKey) -> crate::c_types::Transaction { + let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*commitment_txid }[..]).unwrap(), feerate_per_kw, contest_delay, unsafe { &*htlc.inner }, &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust()); crate::c_types::Transaction::from_bitcoin(&ret) } @@ -1494,7 +1500,12 @@ pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &TrustedC local_ret } -/// Get the transaction number obscure factor +/// 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. #[no_mangle] pub extern "C" fn get_commitment_transaction_number_obscure_factor(mut broadcaster_payment_basepoint: crate::c_types::PublicKey, mut countersignatory_payment_basepoint: crate::c_types::PublicKey, mut outbound_from_broadcaster: bool) -> u64 { let mut ret = lightning::ln::chan_utils::get_commitment_transaction_number_obscure_factor(&broadcaster_payment_basepoint.into_rust(), &countersignatory_payment_basepoint.into_rust(), outbound_from_broadcaster); diff --git a/lightning-c-bindings/src/lightning/ln/channelmanager.rs b/lightning-c-bindings/src/lightning/ln/channelmanager.rs index 9b46a8c..164e944 100644 --- a/lightning-c-bindings/src/lightning/ln/channelmanager.rs +++ b/lightning-c-bindings/src/lightning/ln/channelmanager.rs @@ -186,6 +186,25 @@ pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network:: best_block: *unsafe { Box::from_raw(best_block_arg.take_inner()) }, })), is_owned: true } } +impl Clone for ChainParameters { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChainParameters>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*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 ChainParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChainParameters)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChainParameters +pub extern "C" fn ChainParameters_clone(orig: &ChainParameters) -> ChainParameters { + orig.clone() +} use lightning::ln::channelmanager::BestBlock as nativeBestBlockImport; type nativeBestBlock = nativeBestBlockImport; diff --git a/lightning-c-bindings/src/lightning/util/events.rs b/lightning-c-bindings/src/lightning/util/events.rs index 944d861..cb28df8 100644 --- a/lightning-c-bindings/src/lightning/util/events.rs +++ b/lightning-c-bindings/src/lightning/util/events.rs @@ -115,7 +115,8 @@ pub enum Event { /// now + 5*time_forwardable). time_forwardable: u64, }, - /// Used to indicate that an output was generated on-chain which you should know how to spend. + /// Used to indicate that an output which you should know how to spend was confirmed on chain + /// and is now spendable. /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your /// counterparty spending them due to some kind of timeout. Thus, you need to store them /// somewhere and spend them when you create on-chain transactions. diff --git a/lightning-c-bindings/src/lightning_invoice/mod.rs b/lightning-c-bindings/src/lightning_invoice/mod.rs index f8db6ef..ef1bb7b 100644 --- a/lightning-c-bindings/src/lightning_invoice/mod.rs +++ b/lightning-c-bindings/src/lightning_invoice/mod.rs @@ -617,8 +617,10 @@ pub enum Currency { BitcoinTestnet, /// Bitcoin regtest Regtest, - /// Bitcoin simnet/signet + /// Bitcoin simnet Simnet, + /// Bitcoin signet + Signet, } use lightning_invoice::Currency as nativeCurrency; impl Currency { @@ -629,6 +631,7 @@ impl Currency { Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet, Currency::Regtest => nativeCurrency::Regtest, Currency::Simnet => nativeCurrency::Simnet, + Currency::Signet => nativeCurrency::Signet, } } #[allow(unused)] @@ -638,6 +641,7 @@ impl Currency { Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet, Currency::Regtest => nativeCurrency::Regtest, Currency::Simnet => nativeCurrency::Simnet, + Currency::Signet => nativeCurrency::Signet, } } #[allow(unused)] @@ -647,6 +651,7 @@ impl Currency { nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet, nativeCurrency::Regtest => Currency::Regtest, nativeCurrency::Simnet => Currency::Simnet, + nativeCurrency::Signet => Currency::Signet, } } #[allow(unused)] @@ -656,6 +661,7 @@ impl Currency { nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet, nativeCurrency::Regtest => Currency::Regtest, nativeCurrency::Simnet => Currency::Simnet, + nativeCurrency::Signet => Currency::Signet, } } }