]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Regenerate auto-generated bindings
authorMatt Corallo <git@bluematt.me>
Tue, 8 Jun 2021 02:00:06 +0000 (02:00 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 8 Jun 2021 03:28:43 +0000 (03:28 +0000)
lightning-c-bindings/include/lightning.h
lightning-c-bindings/src/lightning/chain/mod.rs
lightning-c-bindings/src/lightning/ln/chan_utils.rs
lightning-c-bindings/src/lightning/ln/channelmanager.rs
lightning-c-bindings/src/lightning/util/events.rs
lightning-c-bindings/src/lightning_invoice/mod.rs

index c6c97b7cadad2da7353c1d9d013ba2432d43ecb1..8d27f343936b3071c1a28a4cce38d788ae88a072 100644 (file)
@@ -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);
 
index 63d70e3ebefa49dff37106fad5be87d715a85810..d2704fa042968e6fd3db6142ac6f342edc9829bf 100644 (file)
@@ -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)
+}
index 529beacb5afd8c9fc45ef1c8d3b6dde17f8172ee..90dd91fe4e63967bb66a1322f62ff7ce0378ccf5 100644 (file)
@@ -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);
index 9b46a8c3f0b9182ba090fa0186719fe1d33b62df..164e944bff7277a91167176960de02e5f7887109 100644 (file)
@@ -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;
index 944d86159ab2a60a847be85c67dda2004a4394a7..cb28df82f252669b840434264f4e502570c29aae 100644 (file)
@@ -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.
index f8db6ef5aaecdc6f99952862fe6970cd2d856726..ef1bb7b4672a0bfea4de67777cb0763a99147627 100644 (file)
@@ -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,
                }
        }
 }