*/
LDKCurrency_Regtest,
/**
- * Bitcoin simnet/signet
+ * Bitcoin simnet
*/
LDKCurrency_Simnet,
+ /**
+ * Bitcoin signet
+ */
+ LDKCurrency_Signet,
/**
* Must be last for serialization purposes
*/
*/
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.
*/
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
*/
*/
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.
*/
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.
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);
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)
+}
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)
}
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);
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;
/// 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.
BitcoinTestnet,
/// Bitcoin regtest
Regtest,
- /// Bitcoin simnet/signet
+ /// Bitcoin simnet
Simnet,
+ /// Bitcoin signet
+ Signet,
}
use lightning_invoice::Currency as nativeCurrency;
impl Currency {
Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet,
Currency::Regtest => nativeCurrency::Regtest,
Currency::Simnet => nativeCurrency::Simnet,
+ Currency::Signet => nativeCurrency::Signet,
}
}
#[allow(unused)]
Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet,
Currency::Regtest => nativeCurrency::Regtest,
Currency::Simnet => nativeCurrency::Simnet,
+ Currency::Signet => nativeCurrency::Signet,
}
}
#[allow(unused)]
nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet,
nativeCurrency::Regtest => Currency::Regtest,
nativeCurrency::Simnet => Currency::Simnet,
+ nativeCurrency::Signet => Currency::Signet,
}
}
#[allow(unused)]
nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet,
nativeCurrency::Regtest => Currency::Regtest,
nativeCurrency::Simnet => Currency::Simnet,
+ nativeCurrency::Signet => Currency::Signet,
}
}
}