Skip to content

Commit 3ab460c

Browse files
committed
Update bindings after merge of lightningdevkit#633.
1 parent dfe8cf8 commit 3ab460c

File tree

7 files changed

+694
-666
lines changed

7 files changed

+694
-666
lines changed

lightning-c-bindings/include/lightning.h

Lines changed: 130 additions & 116 deletions
Large diffs are not rendered by default.

lightning-c-bindings/include/lightningpp.hpp

Lines changed: 437 additions & 437 deletions
Large diffs are not rendered by default.

lightning-c-bindings/include/rust_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ struct nativeChannelPublicKeysOpaque;
122122
typedef struct nativeChannelPublicKeysOpaque LDKnativeChannelPublicKeys;
123123
struct nativeHTLCOutputInCommitmentOpaque;
124124
typedef struct nativeHTLCOutputInCommitmentOpaque LDKnativeHTLCOutputInCommitment;
125-
struct nativeLocalCommitmentTransactionOpaque;
126-
typedef struct nativeLocalCommitmentTransactionOpaque LDKnativeLocalCommitmentTransaction;
125+
struct nativeHolderCommitmentTransactionOpaque;
126+
typedef struct nativeHolderCommitmentTransactionOpaque LDKnativeHolderCommitmentTransaction;
127127
struct nativeInitFeaturesOpaque;
128128
typedef struct nativeInitFeaturesOpaque LDKnativeInitFeatures;
129129
struct nativeNodeFeaturesOpaque;

lightning-c-bindings/src/chain/keysinterface.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub enum SpendableOutputDescriptor {
4444
/// ChannelKeys::pubkeys().
4545
///
4646
/// To derive the revocation_pubkey provided here (which is used in the witness
47-
/// script generation), you must pass the revocation_basepoint (which appears in the
47+
/// script generation), you must pass the counterparty revocation_basepoint (which appears in the
4848
/// call to ChannelKeys::on_accept) and the provided per_commitment point
4949
/// to chan_utils::derive_public_revocation_key.
5050
///
@@ -261,7 +261,7 @@ pub struct ChannelKeys {
261261
/// TODO: return a Result so we can signal a validation error
262262
#[must_use]
263263
pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes,
264-
/// Gets the local channel public keys and basepoints
264+
/// Gets the holder's channel public keys and basepoints
265265
pub pubkeys: crate::ln::chan_utils::ChannelPublicKeys,
266266
/// Fill in the pubkeys field as a reference to it will be given to Rust after this returns
267267
/// Note that this takes a pointer to this object, not the this_ptr like other methods do
@@ -272,18 +272,18 @@ pub struct ChannelKeys {
272272
/// ChannelKeys object uniquely and lookup or re-derive its keys.
273273
#[must_use]
274274
pub key_derivation_params: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::C2Tuple_u64u64Z,
275-
/// Create a signature for a counterparty commitment transaction and associated HTLC transactions.
275+
/// Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
276276
///
277277
/// Note that if signing fails or is rejected, the channel will be force-closed.
278278
#[must_use]
279279
pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, feerate_per_kw: u32, commitment_tx: crate::c_types::Transaction, keys: &crate::ln::chan_utils::PreCalculatedTxCreationKeys, htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ,
280-
/// Create a signature for a local commitment transaction. This will only ever be called with
281-
/// the same local_commitment_tx (or a copy thereof), though there are currently no guarantees
280+
/// Create a signature for a holder's commitment transaction. This will only ever be called with
281+
/// the same holder_commitment_tx (or a copy thereof), though there are currently no guarantees
282282
/// that it will not be called multiple times.
283283
/// An external signer implementation should check that the commitment has not been revoked.
284284
#[must_use]
285285
pub sign_holder_commitment: extern "C" fn (this_arg: *const c_void, holder_commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ,
286-
/// Create a signature for each HTLC transaction spending a holder commitment transaction.
286+
/// Create a signature for each HTLC transaction spending a holder's commitment transaction.
287287
///
288288
/// Unlike sign_holder_commitment, this may be called multiple times with *different*
289289
/// holder_commitment_tx values. While this will never be called with a revoked
@@ -309,16 +309,16 @@ pub struct ChannelKeys {
309309
/// Amount is value of the output spent by this input, committed to in the BIP 143 signature.
310310
///
311311
/// per_commitment_key is revocation secret which was provided by our counterparty when they
312-
/// revoked the state which they eventually broadcast. It's not a _local_ secret key and does
313-
/// not allow the spending of any funds by itself (you need our local revocation_secret to do
312+
/// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
313+
/// not allow the spending of any funds by itself (you need our holder revocation_secret to do
314314
/// so).
315315
///
316316
/// htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus
317317
/// changing the format of the witness script (which is committed to in the BIP 143
318318
/// signatures).
319319
#[must_use]
320320
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,
321-
/// Create a signature for a claiming transaction for a HTLC output on a counterparty commitment
321+
/// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
322322
/// transaction, either offered or received.
323323
///
324324
/// Such a transaction may claim multiples offered outputs at same time if we know the
@@ -351,13 +351,13 @@ pub struct ChannelKeys {
351351
/// protocol.
352352
#[must_use]
353353
pub sign_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ,
354-
/// Set the counterparty channel basepoints and counterparty/local to_self_delay.
354+
/// Set the counterparty channel basepoints and counterparty_selected/holder_selected_contest_delay.
355355
/// This is done immediately on incoming channels and as soon as the channel is accepted on outgoing channels.
356356
///
357-
/// We bind local_to_self_delay late here for API convenience.
357+
/// We bind holder_selected_contest_delay late here for API convenience.
358358
///
359359
/// Will be called before any signatures are applied.
360-
pub on_accept: extern "C" fn (this_arg: *mut c_void, channel_points: &crate::ln::chan_utils::ChannelPublicKeys, counterparty_to_self_delay: u16, local_to_self_delay: u16),
360+
pub on_accept: extern "C" fn (this_arg: *mut c_void, channel_points: &crate::ln::chan_utils::ChannelPublicKeys, counterparty_selected_contest_delay: u16, holder_selected_contest_delay: u16),
361361
pub clone: Option<extern "C" fn (this_arg: *const c_void) -> *mut c_void>,
362362
pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
363363
}
@@ -413,13 +413,13 @@ impl rustChannelKeys for ChannelKeys {
413413
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(ret.contents.result.take_ptr()) }).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(ret.contents.err.take_ptr()) })*/ })};
414414
local_ret
415415
}
416-
fn sign_holder_commitment<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, local_commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
417-
let mut ret = (self.sign_holder_commitment)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (local_commitment_tx as *const _) as *mut _ }, is_owned: false });
416+
fn sign_holder_commitment<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, holder_commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
417+
let mut ret = (self.sign_holder_commitment)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (holder_commitment_tx as *const _) as *mut _ }, is_owned: false });
418418
let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
419419
local_ret
420420
}
421-
fn sign_holder_commitment_htlc_transactions<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, local_commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<Vec<Option<bitcoin::secp256k1::Signature>>, ()> {
422-
let mut ret = (self.sign_holder_commitment_htlc_transactions)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (local_commitment_tx as *const _) as *mut _ }, is_owned: false });
421+
fn sign_holder_commitment_htlc_transactions<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, holder_commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<Vec<Option<bitcoin::secp256k1::Signature>>, ()> {
422+
let mut ret = (self.sign_holder_commitment_htlc_transactions)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (holder_commitment_tx as *const _) as *mut _ }, is_owned: false });
423423
let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust().drain(..) { local_ret_0.push( { let mut local_ret_0_0 = if item.is_null() { None } else { Some( { item.into_rust() }) }; local_ret_0_0 }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
424424
local_ret
425425
}
@@ -447,8 +447,8 @@ impl rustChannelKeys for ChannelKeys {
447447
let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
448448
local_ret
449449
}
450-
fn on_accept(&mut self, channel_points: &lightning::ln::chan_utils::ChannelPublicKeys, counterparty_to_self_delay: u16, local_to_self_delay: u16) {
451-
(self.on_accept)(self.this_arg, &crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { (channel_points as *const _) as *mut _ }, is_owned: false }, counterparty_to_self_delay, local_to_self_delay)
450+
fn on_accept(&mut self, channel_points: &lightning::ln::chan_utils::ChannelPublicKeys, counterparty_selected_contest_delay: u16, holder_selected_contest_delay: u16) {
451+
(self.on_accept)(self.this_arg, &crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { (channel_points as *const _) as *mut _ }, is_owned: false }, counterparty_selected_contest_delay, holder_selected_contest_delay)
452452
}
453453
}
454454

@@ -602,46 +602,46 @@ pub extern "C" fn InMemoryChannelKeys_get_funding_key(this_ptr: &InMemoryChannel
602602
pub extern "C" fn InMemoryChannelKeys_set_funding_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
603603
unsafe { &mut *this_ptr.inner }.funding_key = val.into_rust();
604604
}
605-
/// Local secret key for blinded revocation pubkey
605+
/// Holder secret key for blinded revocation pubkey
606606
#[no_mangle]
607607
pub extern "C" fn InMemoryChannelKeys_get_revocation_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
608608
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_base_key;
609609
(*inner_val).as_ref()
610610
}
611-
/// Local secret key for blinded revocation pubkey
611+
/// Holder secret key for blinded revocation pubkey
612612
#[no_mangle]
613613
pub extern "C" fn InMemoryChannelKeys_set_revocation_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
614614
unsafe { &mut *this_ptr.inner }.revocation_base_key = val.into_rust();
615615
}
616-
/// Local secret key used for our balance in counterparty-broadcasted commitment transactions
616+
/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions
617617
#[no_mangle]
618618
pub extern "C" fn InMemoryChannelKeys_get_payment_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
619619
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_key;
620620
(*inner_val).as_ref()
621621
}
622-
/// Local secret key used for our balance in counterparty-broadcasted commitment transactions
622+
/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions
623623
#[no_mangle]
624624
pub extern "C" fn InMemoryChannelKeys_set_payment_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
625625
unsafe { &mut *this_ptr.inner }.payment_key = val.into_rust();
626626
}
627-
/// Local secret key used in HTLC tx
627+
/// Holder secret key used in HTLC tx
628628
#[no_mangle]
629629
pub extern "C" fn InMemoryChannelKeys_get_delayed_payment_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
630630
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_base_key;
631631
(*inner_val).as_ref()
632632
}
633-
/// Local secret key used in HTLC tx
633+
/// Holder secret key used in HTLC tx
634634
#[no_mangle]
635635
pub extern "C" fn InMemoryChannelKeys_set_delayed_payment_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
636636
unsafe { &mut *this_ptr.inner }.delayed_payment_base_key = val.into_rust();
637637
}
638-
/// Local htlc secret key used in commitment tx htlc outputs
638+
/// Holder htlc secret key used in commitment tx htlc outputs
639639
#[no_mangle]
640640
pub extern "C" fn InMemoryChannelKeys_get_htlc_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
641641
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_base_key;
642642
(*inner_val).as_ref()
643643
}
644-
/// Local htlc secret key used in commitment tx htlc outputs
644+
/// Holder htlc secret key used in commitment tx htlc outputs
645645
#[no_mangle]
646646
pub extern "C" fn InMemoryChannelKeys_set_htlc_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
647647
unsafe { &mut *this_ptr.inner }.htlc_base_key = val.into_rust();
@@ -675,10 +675,10 @@ pub extern "C" fn InMemoryChannelKeys_counterparty_pubkeys(this_arg: &InMemoryCh
675675
crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
676676
}
677677

678-
/// The contest delay value specified by our counterparty and applied on holder-broadcastable
678+
/// The contest_delay value specified by our counterparty and applied on holder-broadcastable
679679
/// transactions, ie the amount of time that we have to wait to recover our funds if we
680680
/// broadcast a transaction. You'll likely want to pass this to the
681-
/// ln::chan_utils::build*_transaction functions when signing holder transactions.
681+
/// ln::chan_utils::build*_transaction functions when signing holder's transactions.
682682
/// Will panic if on_accept wasn't called.
683683
#[must_use]
684684
#[no_mangle]
@@ -687,7 +687,7 @@ pub extern "C" fn InMemoryChannelKeys_counterparty_selected_contest_delay(this_a
687687
ret
688688
}
689689

690-
/// The to_contest delay value specified by us and applied on transactions broadcastable
690+
/// The contest_delay value specified by us and applied on transactions broadcastable
691691
/// by our counterparty, ie the amount of time that they have to wait to recover their funds
692692
/// if they broadcast a transaction.
693693
/// Will panic if on_accept wasn't called.
@@ -757,14 +757,14 @@ extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment(this_
757757
local_ret
758758
}
759759
#[must_use]
760-
extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment(this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ {
761-
let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment(unsafe { &*local_commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
760+
extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment(this_arg: *const c_void, holder_commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ {
761+
let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment(unsafe { &*holder_commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
762762
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
763763
local_ret
764764
}
765765
#[must_use]
766-
extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_htlc_transactions(this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ {
767-
let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment_htlc_transactions(unsafe { &*local_commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
766+
extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_htlc_transactions(this_arg: *const c_void, holder_commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ {
767+
let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment_htlc_transactions(unsafe { &*holder_commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
768768
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = if item.is_none() { crate::c_types::Signature::null() } else { { crate::c_types::Signature::from_rust(&(item.unwrap())) } }; local_ret_0_0 }); }; local_ret_0.into() }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
769769
local_ret
770770
}

0 commit comments

Comments
 (0)