1 //! keysinterface provides keys into rust-lightning and defines some useful enums which describe
2 //! spendable on-chain outputs which the user owns and is responsible for using just as any other
3 //! on-chain output which is theirs.
6 use bitcoin::hashes::Hash;
10 use lightning::chain::keysinterface::DelayedPaymentOutputDescriptor as nativeDelayedPaymentOutputDescriptorImport;
11 type nativeDelayedPaymentOutputDescriptor = nativeDelayedPaymentOutputDescriptorImport;
13 /// Information about a spendable output to a P2WSH script. See
14 /// SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this.
17 pub struct DelayedPaymentOutputDescriptor {
18 /// Nearly everywhere, inner must be non-null, however in places where
19 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
20 pub inner: *mut nativeDelayedPaymentOutputDescriptor,
24 impl Drop for DelayedPaymentOutputDescriptor {
26 if self.is_owned && !self.inner.is_null() {
27 let _ = unsafe { Box::from_raw(self.inner) };
32 pub extern "C" fn DelayedPaymentOutputDescriptor_free(this_ptr: DelayedPaymentOutputDescriptor) { }
34 /// Used only if an object of this type is returned as a trait impl by a method
35 extern "C" fn DelayedPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) {
36 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDelayedPaymentOutputDescriptor); }
39 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
40 impl DelayedPaymentOutputDescriptor {
41 pub(crate) fn take_inner(mut self) -> *mut nativeDelayedPaymentOutputDescriptor {
42 assert!(self.is_owned);
44 self.inner = std::ptr::null_mut();
48 /// The outpoint which is spendable
50 pub extern "C" fn DelayedPaymentOutputDescriptor_get_outpoint(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::chain::transaction::OutPoint {
51 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint;
52 crate::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
54 /// The outpoint which is spendable
56 pub extern "C" fn DelayedPaymentOutputDescriptor_set_outpoint(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::chain::transaction::OutPoint) {
57 unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) };
59 /// Per commitment point to derive delayed_payment_key by key holder
61 pub extern "C" fn DelayedPaymentOutputDescriptor_get_per_commitment_point(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey {
62 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_point;
63 crate::c_types::PublicKey::from_rust(&(*inner_val))
65 /// Per commitment point to derive delayed_payment_key by key holder
67 pub extern "C" fn DelayedPaymentOutputDescriptor_set_per_commitment_point(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) {
68 unsafe { &mut *this_ptr.inner }.per_commitment_point = val.into_rust();
70 /// The nSequence value which must be set in the spending input to satisfy the OP_CSV in
71 /// the witness_script.
73 pub extern "C" fn DelayedPaymentOutputDescriptor_get_to_self_delay(this_ptr: &DelayedPaymentOutputDescriptor) -> u16 {
74 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
77 /// The nSequence value which must be set in the spending input to satisfy the OP_CSV in
78 /// the witness_script.
80 pub extern "C" fn DelayedPaymentOutputDescriptor_set_to_self_delay(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u16) {
81 unsafe { &mut *this_ptr.inner }.to_self_delay = val;
83 /// The output which is referenced by the given outpoint
85 pub extern "C" fn DelayedPaymentOutputDescriptor_set_output(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::TxOut) {
86 unsafe { &mut *this_ptr.inner }.output = val.into_rust();
88 /// The revocation point specific to the commitment transaction which was broadcast. Used to
89 /// derive the witnessScript for this output.
91 pub extern "C" fn DelayedPaymentOutputDescriptor_get_revocation_pubkey(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey {
92 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_pubkey;
93 crate::c_types::PublicKey::from_rust(&(*inner_val))
95 /// The revocation point specific to the commitment transaction which was broadcast. Used to
96 /// derive the witnessScript for this output.
98 pub extern "C" fn DelayedPaymentOutputDescriptor_set_revocation_pubkey(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) {
99 unsafe { &mut *this_ptr.inner }.revocation_pubkey = val.into_rust();
101 /// Arbitrary identification information returned by a call to
102 /// `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
103 /// the channel to spend the output.
105 pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &DelayedPaymentOutputDescriptor) -> *const [u8; 32] {
106 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_keys_id;
109 /// Arbitrary identification information returned by a call to
110 /// `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
111 /// the channel to spend the output.
113 pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) {
114 unsafe { &mut *this_ptr.inner }.channel_keys_id = val.data;
116 /// The value of the channel which this output originated from, possibly indirectly.
118 pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &DelayedPaymentOutputDescriptor) -> u64 {
119 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis;
122 /// The value of the channel which this output originated from, possibly indirectly.
124 pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u64) {
125 unsafe { &mut *this_ptr.inner }.channel_value_satoshis = val;
129 pub extern "C" fn DelayedPaymentOutputDescriptor_new(mut outpoint_arg: crate::chain::transaction::OutPoint, mut per_commitment_point_arg: crate::c_types::PublicKey, mut to_self_delay_arg: u16, mut output_arg: crate::c_types::TxOut, mut revocation_pubkey_arg: crate::c_types::PublicKey, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> DelayedPaymentOutputDescriptor {
130 DelayedPaymentOutputDescriptor { inner: Box::into_raw(Box::new(nativeDelayedPaymentOutputDescriptor {
131 outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) },
132 per_commitment_point: per_commitment_point_arg.into_rust(),
133 to_self_delay: to_self_delay_arg,
134 output: output_arg.into_rust(),
135 revocation_pubkey: revocation_pubkey_arg.into_rust(),
136 channel_keys_id: channel_keys_id_arg.data,
137 channel_value_satoshis: channel_value_satoshis_arg,
138 })), is_owned: true }
140 impl Clone for DelayedPaymentOutputDescriptor {
141 fn clone(&self) -> Self {
143 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
144 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
150 /// Used only if an object of this type is returned as a trait impl by a method
151 pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
152 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDelayedPaymentOutputDescriptor)).clone() })) as *mut c_void
155 pub extern "C" fn DelayedPaymentOutputDescriptor_clone(orig: &DelayedPaymentOutputDescriptor) -> DelayedPaymentOutputDescriptor {
159 use lightning::chain::keysinterface::StaticPaymentOutputDescriptor as nativeStaticPaymentOutputDescriptorImport;
160 type nativeStaticPaymentOutputDescriptor = nativeStaticPaymentOutputDescriptorImport;
162 /// Information about a spendable output to our \"payment key\". See
163 /// SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this.
166 pub struct StaticPaymentOutputDescriptor {
167 /// Nearly everywhere, inner must be non-null, however in places where
168 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
169 pub inner: *mut nativeStaticPaymentOutputDescriptor,
173 impl Drop for StaticPaymentOutputDescriptor {
175 if self.is_owned && !self.inner.is_null() {
176 let _ = unsafe { Box::from_raw(self.inner) };
181 pub extern "C" fn StaticPaymentOutputDescriptor_free(this_ptr: StaticPaymentOutputDescriptor) { }
183 /// Used only if an object of this type is returned as a trait impl by a method
184 extern "C" fn StaticPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) {
185 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeStaticPaymentOutputDescriptor); }
188 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
189 impl StaticPaymentOutputDescriptor {
190 pub(crate) fn take_inner(mut self) -> *mut nativeStaticPaymentOutputDescriptor {
191 assert!(self.is_owned);
192 let ret = self.inner;
193 self.inner = std::ptr::null_mut();
197 /// The outpoint which is spendable
199 pub extern "C" fn StaticPaymentOutputDescriptor_get_outpoint(this_ptr: &StaticPaymentOutputDescriptor) -> crate::chain::transaction::OutPoint {
200 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint;
201 crate::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
203 /// The outpoint which is spendable
205 pub extern "C" fn StaticPaymentOutputDescriptor_set_outpoint(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::chain::transaction::OutPoint) {
206 unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) };
208 /// The output which is referenced by the given outpoint
210 pub extern "C" fn StaticPaymentOutputDescriptor_set_output(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::TxOut) {
211 unsafe { &mut *this_ptr.inner }.output = val.into_rust();
213 /// Arbitrary identification information returned by a call to
214 /// `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
215 /// the channel to spend the output.
217 pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &StaticPaymentOutputDescriptor) -> *const [u8; 32] {
218 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_keys_id;
221 /// Arbitrary identification information returned by a call to
222 /// `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
223 /// the channel to spend the output.
225 pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) {
226 unsafe { &mut *this_ptr.inner }.channel_keys_id = val.data;
228 /// The value of the channel which this transactions spends.
230 pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &StaticPaymentOutputDescriptor) -> u64 {
231 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis;
234 /// The value of the channel which this transactions spends.
236 pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: u64) {
237 unsafe { &mut *this_ptr.inner }.channel_value_satoshis = val;
241 pub extern "C" fn StaticPaymentOutputDescriptor_new(mut outpoint_arg: crate::chain::transaction::OutPoint, mut output_arg: crate::c_types::TxOut, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> StaticPaymentOutputDescriptor {
242 StaticPaymentOutputDescriptor { inner: Box::into_raw(Box::new(nativeStaticPaymentOutputDescriptor {
243 outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) },
244 output: output_arg.into_rust(),
245 channel_keys_id: channel_keys_id_arg.data,
246 channel_value_satoshis: channel_value_satoshis_arg,
247 })), is_owned: true }
249 impl Clone for StaticPaymentOutputDescriptor {
250 fn clone(&self) -> Self {
252 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
253 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
259 /// Used only if an object of this type is returned as a trait impl by a method
260 pub(crate) extern "C" fn StaticPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
261 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeStaticPaymentOutputDescriptor)).clone() })) as *mut c_void
264 pub extern "C" fn StaticPaymentOutputDescriptor_clone(orig: &StaticPaymentOutputDescriptor) -> StaticPaymentOutputDescriptor {
268 use lightning::chain::keysinterface::SpendableOutputDescriptor as nativeSpendableOutputDescriptorImport;
269 type nativeSpendableOutputDescriptor = nativeSpendableOutputDescriptorImport;
271 /// When on-chain outputs are created by rust-lightning (which our counterparty is not able to
272 /// claim at any point in the future) an event is generated which you must track and be able to
273 /// spend on-chain. The information needed to do this is provided in this enum, including the
274 /// outpoint describing which txid and output index is available, the full output which exists at
275 /// that txid/index, and any keys or other information required to sign.
278 pub struct SpendableOutputDescriptor {
279 /// Nearly everywhere, inner must be non-null, however in places where
280 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
281 pub inner: *mut nativeSpendableOutputDescriptor,
285 impl Drop for SpendableOutputDescriptor {
287 if self.is_owned && !self.inner.is_null() {
288 let _ = unsafe { Box::from_raw(self.inner) };
293 pub extern "C" fn SpendableOutputDescriptor_free(this_ptr: SpendableOutputDescriptor) { }
295 /// Used only if an object of this type is returned as a trait impl by a method
296 extern "C" fn SpendableOutputDescriptor_free_void(this_ptr: *mut c_void) {
297 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeSpendableOutputDescriptor); }
300 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
301 impl SpendableOutputDescriptor {
302 pub(crate) fn take_inner(mut self) -> *mut nativeSpendableOutputDescriptor {
303 assert!(self.is_owned);
304 let ret = self.inner;
305 self.inner = std::ptr::null_mut();
309 impl Clone for SpendableOutputDescriptor {
310 fn clone(&self) -> Self {
312 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
313 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
319 /// Used only if an object of this type is returned as a trait impl by a method
320 pub(crate) extern "C" fn SpendableOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
321 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeSpendableOutputDescriptor)).clone() })) as *mut c_void
324 pub extern "C" fn SpendableOutputDescriptor_clone(orig: &SpendableOutputDescriptor) -> SpendableOutputDescriptor {
328 pub extern "C" fn SpendableOutputDescriptor_write(obj: &SpendableOutputDescriptor) -> crate::c_types::derived::CVec_u8Z {
329 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
332 pub(crate) extern "C" fn SpendableOutputDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
333 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpendableOutputDescriptor) })
336 pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpendableOutputDescriptorDecodeErrorZ {
337 let res = crate::c_types::deserialize_obj(ser);
338 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::chain::keysinterface::SpendableOutputDescriptor { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
341 /// Set of lightning keys needed to operate a channel as described in BOLT 3.
343 /// Signing services could be implemented on a hardware wallet. In this case,
344 /// the current ChannelKeys would be a front-end on top of a communication
345 /// channel connected to your secure device and lightning key material wouldn't
346 /// reside on a hot server. Nevertheless, a this deployment would still need
347 /// to trust the ChannelManager to avoid loss of funds as this latest component
348 /// could ask to sign commitment transaction with HTLCs paying to attacker pubkeys.
350 /// A more secure iteration would be to use hashlock (or payment points) to pair
351 /// invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager
352 /// at the price of more state and computation on the hardware wallet side. In the future,
353 /// we are looking forward to design such interface.
355 /// In any case, ChannelMonitor or fallback watchtowers are always going to be trusted
356 /// to act, as liveness and breach reply correctness are always going to be hard requirements
357 /// of LN security model, orthogonal of key management issues.
359 pub struct ChannelKeys {
360 pub this_arg: *mut c_void,
361 /// Gets the per-commitment point for a specific commitment number
363 /// Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
365 pub get_per_commitment_point: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::PublicKey,
366 /// Gets the commitment secret for a specific commitment number as part of the revocation process
368 /// An external signer implementation should error here if the commitment was already signed
369 /// and should refuse to sign it in the future.
371 /// May be called more than once for the same index.
373 /// Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
375 pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes,
376 /// Gets the holder's channel public keys and basepoints
377 pub pubkeys: crate::ln::chan_utils::ChannelPublicKeys,
378 /// Fill in the pubkeys field as a reference to it will be given to Rust after this returns
379 /// Note that this takes a pointer to this object, not the this_ptr like other methods do
380 /// This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating.
381 pub set_pubkeys: Option<extern "C" fn(&ChannelKeys)>,
382 /// Gets an arbitrary identifier describing the set of keys which are provided back to you in
383 /// some SpendableOutputDescriptor types. This should be sufficient to identify this
384 /// ChannelKeys object uniquely and lookup or re-derive its keys.
386 pub channel_keys_id: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes,
387 /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
389 /// Note that if signing fails or is rejected, the channel will be force-closed.
391 pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ,
392 /// Create a signatures for a holder's commitment transaction and its claiming HTLC transactions.
393 /// This will only ever be called with a non-revoked commitment_tx. This will be called with the
394 /// latest commitment_tx when we initiate a force-close.
395 /// This will be called with the previous latest, just to get claiming HTLC signatures, if we are
396 /// reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to
398 /// This may be called multiple times for the same transaction.
400 /// An external signer implementation should check that the commitment has not been revoked.
402 /// May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case.
404 pub sign_holder_commitment_and_htlcs: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ,
405 /// Create a signature for the given input in a transaction spending an HTLC or commitment
406 /// transaction output when our counterparty broadcasts an old state.
408 /// A justice transaction may claim multiples outputs at the same time if timelocks are
409 /// similar, but only a signature for the input at index `input` should be signed for here.
410 /// It may be called multiples time for same output(s) if a fee-bump is needed with regards
411 /// to an upcoming timelock expiration.
413 /// Amount is value of the output spent by this input, committed to in the BIP 143 signature.
415 /// per_commitment_key is revocation secret which was provided by our counterparty when they
416 /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
417 /// not allow the spending of any funds by itself (you need our holder revocation_secret to do
420 /// htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus
421 /// changing the format of the witness script (which is committed to in the BIP 143
424 pub sign_justice_transaction: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ,
425 /// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
426 /// transaction, either offered or received.
428 /// Such a transaction may claim multiples offered outputs at same time if we know the
429 /// preimage for each when we create it, but only the input at index `input` should be
430 /// signed for here. It may be called multiple times for same output(s) if a fee-bump is
431 /// needed with regards to an upcoming timelock expiration.
433 /// Witness_script is either a offered or received script as defined in BOLT3 for HTLC
436 /// Amount is value of the output spent by this input, committed to in the BIP 143 signature.
438 /// Per_commitment_point is the dynamic point corresponding to the channel state
439 /// detected onchain. It has been generated by our counterparty and is used to derive
440 /// channel state keys, which are then included in the witness script and committed to in the
441 /// BIP 143 signature.
443 pub sign_counterparty_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ,
444 /// Create a signature for a (proposed) closing transaction.
446 /// Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
447 /// chosen to forgo their output as dust.
449 pub sign_closing_transaction: extern "C" fn (this_arg: *const c_void, closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ,
450 /// Signs a channel announcement message with our funding key, proving it comes from one
451 /// of the channel participants.
453 /// Note that if this fails or is rejected, the channel will not be publicly announced and
454 /// our counterparty may (though likely will not) close the channel on us for violating the
457 pub sign_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ,
458 /// Set the counterparty static channel data, including basepoints,
459 /// counterparty_selected/holder_selected_contest_delay and funding outpoint.
460 /// This is done as soon as the funding outpoint is known. Since these are static channel data,
461 /// they MUST NOT be allowed to change to different values once set.
463 /// channel_parameters.is_populated() MUST be true.
465 /// We bind holder_selected_contest_delay late here for API convenience.
467 /// Will be called before any signatures are applied.
468 pub ready_channel: extern "C" fn (this_arg: *mut c_void, channel_parameters: &crate::ln::chan_utils::ChannelTransactionParameters),
469 pub clone: Option<extern "C" fn (this_arg: *const c_void) -> *mut c_void>,
470 pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z,
471 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
473 unsafe impl Send for ChannelKeys {}
475 pub extern "C" fn ChannelKeys_clone(orig: &ChannelKeys) -> ChannelKeys {
477 this_arg: if let Some(f) = orig.clone { (f)(orig.this_arg) } else { orig.this_arg },
478 get_per_commitment_point: orig.get_per_commitment_point.clone(),
479 release_commitment_secret: orig.release_commitment_secret.clone(),
480 pubkeys: orig.pubkeys.clone(),
481 set_pubkeys: orig.set_pubkeys.clone(),
482 channel_keys_id: orig.channel_keys_id.clone(),
483 sign_counterparty_commitment: orig.sign_counterparty_commitment.clone(),
484 sign_holder_commitment_and_htlcs: orig.sign_holder_commitment_and_htlcs.clone(),
485 sign_justice_transaction: orig.sign_justice_transaction.clone(),
486 sign_counterparty_htlc_transaction: orig.sign_counterparty_htlc_transaction.clone(),
487 sign_closing_transaction: orig.sign_closing_transaction.clone(),
488 sign_channel_announcement: orig.sign_channel_announcement.clone(),
489 ready_channel: orig.ready_channel.clone(),
490 clone: orig.clone.clone(),
491 write: orig.write.clone(),
492 free: orig.free.clone(),
495 impl Clone for ChannelKeys {
496 fn clone(&self) -> Self {
497 ChannelKeys_clone(self)
500 impl lightning::util::ser::Writeable for ChannelKeys {
501 fn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
502 let vec = (self.write)(self.this_arg);
503 w.write_all(vec.as_slice())
507 use lightning::chain::keysinterface::ChannelKeys as rustChannelKeys;
508 impl rustChannelKeys for ChannelKeys {
509 fn get_per_commitment_point<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, idx: u64, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> bitcoin::secp256k1::key::PublicKey {
510 let mut ret = (self.get_per_commitment_point)(self.this_arg, idx);
513 fn release_commitment_secret(&self, idx: u64) -> [u8; 32] {
514 let mut ret = (self.release_commitment_secret)(self.this_arg, idx);
517 fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys {
518 if let Some(f) = self.set_pubkeys {
521 unsafe { &*self.pubkeys.inner }
523 fn channel_keys_id(&self) -> [u8; 32] {
524 let mut ret = (self.channel_keys_id)(self.this_arg);
527 fn sign_counterparty_commitment<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<(bitcoin::secp256k1::Signature, Vec<bitcoin::secp256k1::Signature>), ()> {
528 let mut ret = (self.sign_counterparty_commitment)(self.this_arg, &crate::ln::chan_utils::CommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false });
529 let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
532 fn sign_holder_commitment_and_htlcs<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<(bitcoin::secp256k1::Signature, Vec<bitcoin::secp256k1::Signature>), ()> {
533 let mut ret = (self.sign_holder_commitment_and_htlcs)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false });
534 let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
537 fn sign_justice_transaction<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, justice_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_key: &bitcoin::secp256k1::key::SecretKey, htlc: &Option<lightning::ln::chan_utils::HTLCOutputInCommitment>, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
538 let mut local_justice_tx = ::bitcoin::consensus::encode::serialize(justice_tx);
539 let mut local_htlc = &crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (if htlc.is_none() { std::ptr::null() } else { { (htlc.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
540 let mut ret = (self.sign_justice_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_justice_tx), input, amount, per_commitment_key.as_ref(), local_htlc);
541 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
544 fn sign_counterparty_htlc_transaction<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, htlc_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_point: &bitcoin::secp256k1::key::PublicKey, htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
545 let mut local_htlc_tx = ::bitcoin::consensus::encode::serialize(htlc_tx);
546 let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (htlc as *const _) as *mut _ }, is_owned: false });
547 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
550 fn sign_closing_transaction<T:bitcoin::secp256k1::Signing>(&self, closing_tx: &bitcoin::blockdata::transaction::Transaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
551 let mut local_closing_tx = ::bitcoin::consensus::encode::serialize(closing_tx);
552 let mut ret = (self.sign_closing_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_closing_tx));
553 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
556 fn sign_channel_announcement<T:bitcoin::secp256k1::Signing>(&self, msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
557 let mut ret = (self.sign_channel_announcement)(self.this_arg, &crate::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
558 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
561 fn ready_channel(&mut self, channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) {
562 (self.ready_channel)(self.this_arg, &crate::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { (channel_parameters as *const _) as *mut _ }, is_owned: false })
566 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
567 // directly as a Deref trait in higher-level structs:
568 impl std::ops::Deref for ChannelKeys {
570 fn deref(&self) -> &Self {
574 /// Calls the free function if one is set
576 pub extern "C" fn ChannelKeys_free(this_ptr: ChannelKeys) { }
577 impl Drop for ChannelKeys {
579 if let Some(f) = self.free {
584 /// A trait to describe an object which can get user secrets and key material.
586 pub struct KeysInterface {
587 pub this_arg: *mut c_void,
588 /// Get node secret key (aka node_id or network_key).
590 /// This method must return the same value each time it is called.
592 pub get_node_secret: extern "C" fn (this_arg: *const c_void) -> crate::c_types::SecretKey,
593 /// Get a script pubkey which we send funds to when claiming on-chain contestable outputs.
595 /// This method should return a different value each time it is called, to avoid linking
596 /// on-chain funds across channels as controlled to the same user.
598 pub get_destination_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z,
599 /// Get a public key which we will send funds to (in the form of a P2WPKH output) when closing
602 /// This method should return a different value each time it is called, to avoid linking
603 /// on-chain funds across channels as controlled to the same user.
605 pub get_shutdown_pubkey: extern "C" fn (this_arg: *const c_void) -> crate::c_types::PublicKey,
606 /// Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
607 /// restarted with some stale data!
609 /// This method must return a different value each time it is called.
611 pub get_channel_keys: extern "C" fn (this_arg: *const c_void, inbound: bool, channel_value_satoshis: u64) -> crate::chain::keysinterface::ChannelKeys,
612 /// Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
613 /// onion packets and for temporary channel IDs. There is no requirement that these be
614 /// persisted anywhere, though they must be unique across restarts.
616 /// This method must return a different value each time it is called.
618 pub get_secure_random_bytes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes,
619 /// Reads a `ChanKeySigner` for this `KeysInterface` from the given input stream.
620 /// This is only called during deserialization of other objects which contain
621 /// `ChannelKeys`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s).
622 /// The bytes are exactly those which `<Self::ChanKeySigner as Writeable>::write()` writes, and
623 /// contain no versioning scheme. You may wish to include your own version prefix and ensure
624 /// you've read all of the provided bytes to ensure no corruption occurred.
626 pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelKeysDecodeErrorZ,
627 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
629 unsafe impl Send for KeysInterface {}
630 unsafe impl Sync for KeysInterface {}
632 use lightning::chain::keysinterface::KeysInterface as rustKeysInterface;
633 impl rustKeysInterface for KeysInterface {
634 type ChanKeySigner = crate::chain::keysinterface::ChannelKeys;
635 fn get_node_secret(&self) -> bitcoin::secp256k1::key::SecretKey {
636 let mut ret = (self.get_node_secret)(self.this_arg);
639 fn get_destination_script(&self) -> bitcoin::blockdata::script::Script {
640 let mut ret = (self.get_destination_script)(self.this_arg);
641 ::bitcoin::blockdata::script::Script::from(ret.into_rust())
643 fn get_shutdown_pubkey(&self) -> bitcoin::secp256k1::key::PublicKey {
644 let mut ret = (self.get_shutdown_pubkey)(self.this_arg);
647 fn get_channel_keys(&self, inbound: bool, channel_value_satoshis: u64) -> crate::chain::keysinterface::ChannelKeys {
648 let mut ret = (self.get_channel_keys)(self.this_arg, inbound, channel_value_satoshis);
651 fn get_secure_random_bytes(&self) -> [u8; 32] {
652 let mut ret = (self.get_secure_random_bytes)(self.this_arg);
655 fn read_chan_signer(&self, reader: &[u8]) -> Result<crate::chain::keysinterface::ChannelKeys, lightning::ln::msgs::DecodeError> {
656 let mut local_reader = crate::c_types::u8slice::from_slice(reader);
657 let mut ret = (self.read_chan_signer)(self.this_arg, local_reader);
658 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
663 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
664 // directly as a Deref trait in higher-level structs:
665 impl std::ops::Deref for KeysInterface {
667 fn deref(&self) -> &Self {
671 /// Calls the free function if one is set
673 pub extern "C" fn KeysInterface_free(this_ptr: KeysInterface) { }
674 impl Drop for KeysInterface {
676 if let Some(f) = self.free {
682 use lightning::chain::keysinterface::InMemoryChannelKeys as nativeInMemoryChannelKeysImport;
683 type nativeInMemoryChannelKeys = nativeInMemoryChannelKeysImport;
685 /// A simple implementation of ChannelKeys that just keeps the private keys in memory.
687 /// This implementation performs no policy checks and is insufficient by itself as
688 /// a secure external signer.
691 pub struct InMemoryChannelKeys {
692 /// Nearly everywhere, inner must be non-null, however in places where
693 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
694 pub inner: *mut nativeInMemoryChannelKeys,
698 impl Drop for InMemoryChannelKeys {
700 if self.is_owned && !self.inner.is_null() {
701 let _ = unsafe { Box::from_raw(self.inner) };
706 pub extern "C" fn InMemoryChannelKeys_free(this_ptr: InMemoryChannelKeys) { }
708 /// Used only if an object of this type is returned as a trait impl by a method
709 extern "C" fn InMemoryChannelKeys_free_void(this_ptr: *mut c_void) {
710 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInMemoryChannelKeys); }
713 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
714 impl InMemoryChannelKeys {
715 pub(crate) fn take_inner(mut self) -> *mut nativeInMemoryChannelKeys {
716 assert!(self.is_owned);
717 let ret = self.inner;
718 self.inner = std::ptr::null_mut();
722 /// Private key of anchor tx
724 pub extern "C" fn InMemoryChannelKeys_get_funding_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
725 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_key;
726 (*inner_val).as_ref()
728 /// Private key of anchor tx
730 pub extern "C" fn InMemoryChannelKeys_set_funding_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
731 unsafe { &mut *this_ptr.inner }.funding_key = val.into_rust();
733 /// Holder secret key for blinded revocation pubkey
735 pub extern "C" fn InMemoryChannelKeys_get_revocation_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
736 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_base_key;
737 (*inner_val).as_ref()
739 /// Holder secret key for blinded revocation pubkey
741 pub extern "C" fn InMemoryChannelKeys_set_revocation_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
742 unsafe { &mut *this_ptr.inner }.revocation_base_key = val.into_rust();
744 /// Holder secret key used for our balance in counterparty-broadcasted commitment transactions
746 pub extern "C" fn InMemoryChannelKeys_get_payment_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
747 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_key;
748 (*inner_val).as_ref()
750 /// Holder secret key used for our balance in counterparty-broadcasted commitment transactions
752 pub extern "C" fn InMemoryChannelKeys_set_payment_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
753 unsafe { &mut *this_ptr.inner }.payment_key = val.into_rust();
755 /// Holder secret key used in HTLC tx
757 pub extern "C" fn InMemoryChannelKeys_get_delayed_payment_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
758 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_base_key;
759 (*inner_val).as_ref()
761 /// Holder secret key used in HTLC tx
763 pub extern "C" fn InMemoryChannelKeys_set_delayed_payment_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
764 unsafe { &mut *this_ptr.inner }.delayed_payment_base_key = val.into_rust();
766 /// Holder htlc secret key used in commitment tx htlc outputs
768 pub extern "C" fn InMemoryChannelKeys_get_htlc_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
769 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_base_key;
770 (*inner_val).as_ref()
772 /// Holder htlc secret key used in commitment tx htlc outputs
774 pub extern "C" fn InMemoryChannelKeys_set_htlc_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
775 unsafe { &mut *this_ptr.inner }.htlc_base_key = val.into_rust();
779 pub extern "C" fn InMemoryChannelKeys_get_commitment_seed(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
780 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_seed;
785 pub extern "C" fn InMemoryChannelKeys_set_commitment_seed(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::ThirtyTwoBytes) {
786 unsafe { &mut *this_ptr.inner }.commitment_seed = val.data;
788 impl Clone for InMemoryChannelKeys {
789 fn clone(&self) -> Self {
791 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
792 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
798 /// Used only if an object of this type is returned as a trait impl by a method
799 pub(crate) extern "C" fn InMemoryChannelKeys_clone_void(this_ptr: *const c_void) -> *mut c_void {
800 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInMemoryChannelKeys)).clone() })) as *mut c_void
803 pub extern "C" fn InMemoryChannelKeys_clone(orig: &InMemoryChannelKeys) -> InMemoryChannelKeys {
806 /// Create a new InMemoryChannelKeys
809 pub extern "C" fn InMemoryChannelKeys_new(mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::chain::keysinterface::InMemoryChannelKeys {
810 let mut ret = lightning::chain::keysinterface::InMemoryChannelKeys::new(&bitcoin::secp256k1::Secp256k1::new(), funding_key.into_rust(), revocation_base_key.into_rust(), payment_key.into_rust(), delayed_payment_base_key.into_rust(), htlc_base_key.into_rust(), commitment_seed.data, channel_value_satoshis, channel_keys_id.data);
811 crate::chain::keysinterface::InMemoryChannelKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true }
814 /// Counterparty pubkeys.
815 /// Will panic if ready_channel wasn't called.
818 pub extern "C" fn InMemoryChannelKeys_counterparty_pubkeys(this_arg: &InMemoryChannelKeys) -> crate::ln::chan_utils::ChannelPublicKeys {
819 let mut ret = unsafe { &*this_arg.inner }.counterparty_pubkeys();
820 crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
823 /// The contest_delay value specified by our counterparty and applied on holder-broadcastable
824 /// transactions, ie the amount of time that we have to wait to recover our funds if we
825 /// broadcast a transaction.
826 /// Will panic if ready_channel wasn't called.
829 pub extern "C" fn InMemoryChannelKeys_counterparty_selected_contest_delay(this_arg: &InMemoryChannelKeys) -> u16 {
830 let mut ret = unsafe { &*this_arg.inner }.counterparty_selected_contest_delay();
834 /// The contest_delay value specified by us and applied on transactions broadcastable
835 /// by our counterparty, ie the amount of time that they have to wait to recover their funds
836 /// if they broadcast a transaction.
837 /// Will panic if ready_channel wasn't called.
840 pub extern "C" fn InMemoryChannelKeys_holder_selected_contest_delay(this_arg: &InMemoryChannelKeys) -> u16 {
841 let mut ret = unsafe { &*this_arg.inner }.holder_selected_contest_delay();
845 /// Whether the holder is the initiator
846 /// Will panic if ready_channel wasn't called.
849 pub extern "C" fn InMemoryChannelKeys_is_outbound(this_arg: &InMemoryChannelKeys) -> bool {
850 let mut ret = unsafe { &*this_arg.inner }.is_outbound();
855 /// Will panic if ready_channel wasn't called.
858 pub extern "C" fn InMemoryChannelKeys_funding_outpoint(this_arg: &InMemoryChannelKeys) -> crate::chain::transaction::OutPoint {
859 let mut ret = unsafe { &*this_arg.inner }.funding_outpoint();
860 crate::chain::transaction::OutPoint { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
863 /// Obtain a ChannelTransactionParameters for this channel, to be used when verifying or
864 /// building transactions.
866 /// Will panic if ready_channel wasn't called.
869 pub extern "C" fn InMemoryChannelKeys_get_channel_parameters(this_arg: &InMemoryChannelKeys) -> crate::ln::chan_utils::ChannelTransactionParameters {
870 let mut ret = unsafe { &*this_arg.inner }.get_channel_parameters();
871 crate::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
874 /// Sign the single input of spend_tx at index `input_idx` which spends the output
875 /// described by descriptor, returning the witness stack for the input.
877 /// Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
878 /// or is not spending the outpoint described by `descriptor.outpoint`.
881 pub extern "C" fn InMemoryChannelKeys_sign_counterparty_payment_input(this_arg: &InMemoryChannelKeys, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::chain::keysinterface::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ {
882 let mut ret = unsafe { &*this_arg.inner }.sign_counterparty_payment_input(&spend_tx.into_bitcoin(), input_idx, unsafe { &*descriptor.inner }, &bitcoin::secp256k1::Secp256k1::new());
883 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
887 /// Sign the single input of spend_tx at index `input_idx` which spends the output
888 /// described by descriptor, returning the witness stack for the input.
890 /// Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
891 /// is not spending the outpoint described by `descriptor.outpoint`, or does not have a
892 /// sequence set to `descriptor.to_self_delay`.
895 pub extern "C" fn InMemoryChannelKeys_sign_dynamic_p2wsh_input(this_arg: &InMemoryChannelKeys, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::chain::keysinterface::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ {
896 let mut ret = unsafe { &*this_arg.inner }.sign_dynamic_p2wsh_input(&spend_tx.into_bitcoin(), input_idx, unsafe { &*descriptor.inner }, &bitcoin::secp256k1::Secp256k1::new());
897 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
901 impl From<nativeInMemoryChannelKeys> for crate::chain::keysinterface::ChannelKeys {
902 fn from(obj: nativeInMemoryChannelKeys) -> Self {
903 let mut rust_obj = InMemoryChannelKeys { inner: Box::into_raw(Box::new(obj)), is_owned: true };
904 let mut ret = InMemoryChannelKeys_as_ChannelKeys(&rust_obj);
905 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
906 rust_obj.inner = std::ptr::null_mut();
907 ret.free = Some(InMemoryChannelKeys_free_void);
912 pub extern "C" fn InMemoryChannelKeys_as_ChannelKeys(this_arg: &InMemoryChannelKeys) -> crate::chain::keysinterface::ChannelKeys {
913 crate::chain::keysinterface::ChannelKeys {
914 this_arg: unsafe { (*this_arg).inner as *mut c_void },
916 get_per_commitment_point: InMemoryChannelKeys_ChannelKeys_get_per_commitment_point,
917 release_commitment_secret: InMemoryChannelKeys_ChannelKeys_release_commitment_secret,
919 pubkeys: crate::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true },
920 set_pubkeys: Some(InMemoryChannelKeys_ChannelKeys_set_pubkeys),
921 channel_keys_id: InMemoryChannelKeys_ChannelKeys_channel_keys_id,
922 sign_counterparty_commitment: InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment,
923 sign_holder_commitment_and_htlcs: InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_and_htlcs,
924 sign_justice_transaction: InMemoryChannelKeys_ChannelKeys_sign_justice_transaction,
925 sign_counterparty_htlc_transaction: InMemoryChannelKeys_ChannelKeys_sign_counterparty_htlc_transaction,
926 sign_closing_transaction: InMemoryChannelKeys_ChannelKeys_sign_closing_transaction,
927 sign_channel_announcement: InMemoryChannelKeys_ChannelKeys_sign_channel_announcement,
928 ready_channel: InMemoryChannelKeys_ChannelKeys_ready_channel,
929 clone: Some(InMemoryChannelKeys_clone_void),
930 write: InMemoryChannelKeys_write_void,
933 use lightning::chain::keysinterface::ChannelKeys as ChannelKeysTraitImport;
935 extern "C" fn InMemoryChannelKeys_ChannelKeys_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey {
936 let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.get_per_commitment_point(idx, &bitcoin::secp256k1::Secp256k1::new());
937 crate::c_types::PublicKey::from_rust(&ret)
940 extern "C" fn InMemoryChannelKeys_ChannelKeys_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes {
941 let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.release_commitment_secret(idx);
942 crate::c_types::ThirtyTwoBytes { data: ret }
945 extern "C" fn InMemoryChannelKeys_ChannelKeys_pubkeys(this_arg: *const c_void) -> crate::ln::chan_utils::ChannelPublicKeys {
946 let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.pubkeys();
947 crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
949 extern "C" fn InMemoryChannelKeys_ChannelKeys_set_pubkeys(trait_self_arg: &ChannelKeys) {
950 // This is a bit race-y in the general case, but for our specific use-cases today, we're safe
951 // Specifically, we must ensure that the first time we're called it can never be in parallel
952 if trait_self_arg.pubkeys.inner.is_null() {
953 unsafe { &mut *(trait_self_arg as *const ChannelKeys as *mut ChannelKeys) }.pubkeys = InMemoryChannelKeys_ChannelKeys_pubkeys(trait_self_arg.this_arg);
957 extern "C" fn InMemoryChannelKeys_ChannelKeys_channel_keys_id(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes {
958 let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.channel_keys_id();
959 crate::c_types::ThirtyTwoBytes { data: ret }
962 extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
963 let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_counterparty_commitment(unsafe { &*commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
964 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
968 extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
969 let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment_and_htlcs(unsafe { &*commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
970 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
974 extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_justice_transaction(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
975 let mut local_htlc = if htlc.inner.is_null() { None } else { Some((* { unsafe { &*htlc.inner } }).clone()) };
976 let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_justice_transaction(&justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), &local_htlc, &bitcoin::secp256k1::Secp256k1::new());
977 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
981 extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
982 let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_counterparty_htlc_transaction(&htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), unsafe { &*htlc.inner }, &bitcoin::secp256k1::Secp256k1::new());
983 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
987 extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_closing_transaction(this_arg: *const c_void, mut closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ {
988 let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_closing_transaction(&closing_tx.into_bitcoin(), &bitcoin::secp256k1::Secp256k1::new());
989 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
993 extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_channel_announcement(this_arg: *const c_void, msg: &crate::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ {
994 let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_channel_announcement(unsafe { &*msg.inner }, &bitcoin::secp256k1::Secp256k1::new());
995 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
998 extern "C" fn InMemoryChannelKeys_ChannelKeys_ready_channel(this_arg: *mut c_void, channel_parameters: &crate::ln::chan_utils::ChannelTransactionParameters) {
999 unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.ready_channel(unsafe { &*channel_parameters.inner })
1003 pub extern "C" fn InMemoryChannelKeys_write(obj: &InMemoryChannelKeys) -> crate::c_types::derived::CVec_u8Z {
1004 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1007 pub(crate) extern "C" fn InMemoryChannelKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1008 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInMemoryChannelKeys) })
1011 pub extern "C" fn InMemoryChannelKeys_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InMemoryChannelKeysDecodeErrorZ {
1012 let res = crate::c_types::deserialize_obj(ser);
1013 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::chain::keysinterface::InMemoryChannelKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1017 use lightning::chain::keysinterface::KeysManager as nativeKeysManagerImport;
1018 type nativeKeysManager = nativeKeysManagerImport;
1020 /// Simple KeysInterface implementor that takes a 32-byte seed for use as a BIP 32 extended key
1021 /// and derives keys from that.
1023 /// Your node_id is seed/0'
1024 /// ChannelMonitor closes may use seed/1'
1025 /// Cooperative closes may use seed/2'
1026 /// The two close keys may be needed to claim on-chain funds!
1029 pub struct KeysManager {
1030 /// Nearly everywhere, inner must be non-null, however in places where
1031 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1032 pub inner: *mut nativeKeysManager,
1036 impl Drop for KeysManager {
1037 fn drop(&mut self) {
1038 if self.is_owned && !self.inner.is_null() {
1039 let _ = unsafe { Box::from_raw(self.inner) };
1044 pub extern "C" fn KeysManager_free(this_ptr: KeysManager) { }
1046 /// Used only if an object of this type is returned as a trait impl by a method
1047 extern "C" fn KeysManager_free_void(this_ptr: *mut c_void) {
1048 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeKeysManager); }
1051 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1053 pub(crate) fn take_inner(mut self) -> *mut nativeKeysManager {
1054 assert!(self.is_owned);
1055 let ret = self.inner;
1056 self.inner = std::ptr::null_mut();
1060 /// Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased (eg your
1061 /// CSRNG is busted) this may panic (but more importantly, you will possibly lose funds).
1062 /// starting_time isn't strictly required to actually be a time, but it must absolutely,
1063 /// without a doubt, be unique to this instance. ie if you start multiple times with the same
1064 /// seed, starting_time must be unique to each run. Thus, the easiest way to achieve this is to
1065 /// simply use the current time (with very high precision).
1067 /// The seed MUST be backed up safely prior to use so that the keys can be re-created, however,
1068 /// obviously, starting_time should be unique every time you reload the library - it is only
1069 /// used to generate new ephemeral key data (which will be stored by the individual channel if
1072 /// Note that the seed is required to recover certain on-chain funds independent of
1073 /// ChannelMonitor data, though a current copy of ChannelMonitor data is also required for any
1074 /// channel, and some on-chain during-closing funds.
1076 /// Note that until the 0.1 release there is no guarantee of backward compatibility between
1077 /// versions. Once the library is more fully supported, the docs will be updated to include a
1078 /// detailed description of the guarantee.
1081 pub extern "C" fn KeysManager_new(seed: *const [u8; 32], mut starting_time_secs: u64, mut starting_time_nanos: u32) -> KeysManager {
1082 let mut ret = lightning::chain::keysinterface::KeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos);
1083 KeysManager { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1086 /// Derive an old set of ChannelKeys for per-channel secrets based on a key derivation
1088 /// Key derivation parameters are accessible through a per-channel secrets
1089 /// ChannelKeys::channel_keys_id and is provided inside DynamicOuputP2WSH in case of
1090 /// onchain output detection for which a corresponding delayed_payment_key must be derived.
1093 pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &KeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::chain::keysinterface::InMemoryChannelKeys {
1094 let mut ret = unsafe { &*this_arg.inner }.derive_channel_keys(channel_value_satoshis, unsafe { &*params});
1095 crate::chain::keysinterface::InMemoryChannelKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1098 /// Creates a Transaction which spends the given descriptors to the given outputs, plus an
1099 /// output to the given change destination (if sufficient change value remains). The
1100 /// transaction will have a feerate, at least, of the given value.
1102 /// Returns `Err(())` if the output value is greater than the input value minus required fee or
1103 /// if a descriptor was duplicated.
1105 /// We do not enforce that outputs meet the dust limit or that any output scripts are standard.
1107 /// May panic if the `SpendableOutputDescriptor`s were not generated by Channels which used
1108 /// this KeysManager or one of the `InMemoryChannelKeys` created by this KeysManager.
1111 pub extern "C" fn KeysManager_spend_spendable_outputs(this_arg: &KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_TransactionNoneZ {
1112 let mut local_descriptors = Vec::new(); for mut item in descriptors.as_slice().iter() { local_descriptors.push( { unsafe { &*item.inner } }); };
1113 let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); };
1114 let mut ret = unsafe { &*this_arg.inner }.spend_spendable_outputs(&local_descriptors[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, &bitcoin::secp256k1::Secp256k1::new());
1115 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&o); crate::c_types::Transaction::from_vec(local_ret_0) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
1119 impl From<nativeKeysManager> for crate::chain::keysinterface::KeysInterface {
1120 fn from(obj: nativeKeysManager) -> Self {
1121 let mut rust_obj = KeysManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
1122 let mut ret = KeysManager_as_KeysInterface(&rust_obj);
1123 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
1124 rust_obj.inner = std::ptr::null_mut();
1125 ret.free = Some(KeysManager_free_void);
1130 pub extern "C" fn KeysManager_as_KeysInterface(this_arg: &KeysManager) -> crate::chain::keysinterface::KeysInterface {
1131 crate::chain::keysinterface::KeysInterface {
1132 this_arg: unsafe { (*this_arg).inner as *mut c_void },
1134 get_node_secret: KeysManager_KeysInterface_get_node_secret,
1135 get_destination_script: KeysManager_KeysInterface_get_destination_script,
1136 get_shutdown_pubkey: KeysManager_KeysInterface_get_shutdown_pubkey,
1137 get_channel_keys: KeysManager_KeysInterface_get_channel_keys,
1138 get_secure_random_bytes: KeysManager_KeysInterface_get_secure_random_bytes,
1139 read_chan_signer: KeysManager_KeysInterface_read_chan_signer,
1142 use lightning::chain::keysinterface::KeysInterface as KeysInterfaceTraitImport;
1144 extern "C" fn KeysManager_KeysInterface_get_node_secret(this_arg: *const c_void) -> crate::c_types::SecretKey {
1145 let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_node_secret();
1146 crate::c_types::SecretKey::from_rust(ret)
1149 extern "C" fn KeysManager_KeysInterface_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1150 let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_destination_script();
1151 ret.into_bytes().into()
1154 extern "C" fn KeysManager_KeysInterface_get_shutdown_pubkey(this_arg: *const c_void) -> crate::c_types::PublicKey {
1155 let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_shutdown_pubkey();
1156 crate::c_types::PublicKey::from_rust(&ret)
1159 extern "C" fn KeysManager_KeysInterface_get_channel_keys(this_arg: *const c_void, mut _inbound: bool, mut channel_value_satoshis: u64) -> crate::chain::keysinterface::ChannelKeys {
1160 let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_channel_keys(_inbound, channel_value_satoshis);
1164 extern "C" fn KeysManager_KeysInterface_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes {
1165 let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_secure_random_bytes();
1166 crate::c_types::ThirtyTwoBytes { data: ret }
1169 extern "C" fn KeysManager_KeysInterface_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelKeysDecodeErrorZ {
1170 let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.read_chan_signer(reader.to_slice());
1171 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };