Skip to content

Commit f337fb2

Browse files
committed
Update auto-generated bindings with aliasing fix.
1 parent cd9dff8 commit f337fb2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

lightning-c-bindings/include/lightning.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7884,7 +7884,7 @@ typedef struct LDKChannelSigner {
78847884
/**
78857885
* Returns the holder's channel public keys and basepoints.
78867886
*/
7887-
struct LDKChannelPublicKeys pubkeys;
7887+
LDKChannelPublicKeys pubkeys;
78887888
/**
78897889
* Fill in the pubkeys field as a reference to it will be given to Rust after this returns
78907890
* Note that this takes a pointer to this object, not the this_ptr like other methods do

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ pub struct ChannelSigner {
629629
#[must_use]
630630
pub validate_holder_commitment: extern "C" fn (this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_NoneNoneZ,
631631
/// Returns the holder's channel public keys and basepoints.
632-
pub pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys,
632+
pub pubkeys: core::cell::UnsafeCell<crate::lightning::ln::chan_utils::ChannelPublicKeys>,
633633
/// Fill in the pubkeys field as a reference to it will be given to Rust after this returns
634634
/// Note that this takes a pointer to this object, not the this_ptr like other methods do
635635
/// This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating.
@@ -662,7 +662,7 @@ pub(crate) extern "C" fn ChannelSigner_clone_fields(orig: &ChannelSigner) -> Cha
662662
get_per_commitment_point: Clone::clone(&orig.get_per_commitment_point),
663663
release_commitment_secret: Clone::clone(&orig.release_commitment_secret),
664664
validate_holder_commitment: Clone::clone(&orig.validate_holder_commitment),
665-
pubkeys: Clone::clone(&orig.pubkeys),
665+
pubkeys: Clone::clone(unsafe { &*core::cell::UnsafeCell::get(&orig.pubkeys)}).into(),
666666
set_pubkeys: Clone::clone(&orig.set_pubkeys),
667667
channel_keys_id: Clone::clone(&orig.channel_keys_id),
668668
provide_channel_parameters: Clone::clone(&orig.provide_channel_parameters),
@@ -690,7 +690,7 @@ impl rustChannelSigner for ChannelSigner {
690690
if let Some(f) = self.set_pubkeys {
691691
(f)(&self);
692692
}
693-
self.pubkeys.get_native_ref()
693+
unsafe { &*self.pubkeys.get() }.get_native_ref()
694694
}
695695
fn channel_keys_id(&self) -> [u8; 32] {
696696
let mut ret = (self.channel_keys_id)(self.this_arg);
@@ -889,7 +889,7 @@ impl lightning::chain::keysinterface::ChannelSigner for EcdsaChannelSigner {
889889
if let Some(f) = self.ChannelSigner.set_pubkeys {
890890
(f)(&self.ChannelSigner);
891891
}
892-
self.ChannelSigner.pubkeys.get_native_ref()
892+
unsafe { &*self.ChannelSigner.pubkeys.get() }.get_native_ref()
893893
}
894894
fn channel_keys_id(&self) -> [u8; 32] {
895895
let mut ret = (self.ChannelSigner.channel_keys_id)(self.ChannelSigner.this_arg);
@@ -1066,7 +1066,7 @@ impl lightning::chain::keysinterface::ChannelSigner for WriteableEcdsaChannelSig
10661066
if let Some(f) = self.EcdsaChannelSigner.ChannelSigner.set_pubkeys {
10671067
(f)(&self.EcdsaChannelSigner.ChannelSigner);
10681068
}
1069-
self.EcdsaChannelSigner.ChannelSigner.pubkeys.get_native_ref()
1069+
unsafe { &*self.EcdsaChannelSigner.ChannelSigner.pubkeys.get() }.get_native_ref()
10701070
}
10711071
fn channel_keys_id(&self) -> [u8; 32] {
10721072
let mut ret = (self.EcdsaChannelSigner.ChannelSigner.channel_keys_id)(self.EcdsaChannelSigner.ChannelSigner.this_arg);
@@ -1761,7 +1761,7 @@ pub extern "C" fn InMemorySigner_as_ChannelSigner(this_arg: &InMemorySigner) ->
17611761
release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret,
17621762
validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment,
17631763

1764-
pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true },
1764+
pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(),
17651765
set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys),
17661766
channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id,
17671767
provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters,
@@ -1793,8 +1793,8 @@ extern "C" fn InMemorySigner_ChannelSigner_pubkeys(this_arg: *const c_void) -> c
17931793
extern "C" fn InMemorySigner_ChannelSigner_set_pubkeys(trait_self_arg: &ChannelSigner) {
17941794
// This is a bit race-y in the general case, but for our specific use-cases today, we're safe
17951795
// Specifically, we must ensure that the first time we're called it can never be in parallel
1796-
if trait_self_arg.pubkeys.inner.is_null() {
1797-
unsafe { &mut *(trait_self_arg as *const ChannelSigner as *mut ChannelSigner) }.pubkeys = InMemorySigner_ChannelSigner_pubkeys(trait_self_arg.this_arg);
1796+
if unsafe { &*trait_self_arg.pubkeys.get() }.inner.is_null() {
1797+
*unsafe { &mut *(&*(trait_self_arg as *const ChannelSigner)).pubkeys.get() } = InMemorySigner_ChannelSigner_pubkeys(trait_self_arg.this_arg).into();
17981798
}
17991799
}
18001800
#[must_use]
@@ -1839,7 +1839,7 @@ pub extern "C" fn InMemorySigner_as_EcdsaChannelSigner(this_arg: &InMemorySigner
18391839
release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret,
18401840
validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment,
18411841

1842-
pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true },
1842+
pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(),
18431843
set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys),
18441844
channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id,
18451845
provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters,
@@ -1939,7 +1939,7 @@ pub extern "C" fn InMemorySigner_as_WriteableEcdsaChannelSigner(this_arg: &InMem
19391939
release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret,
19401940
validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment,
19411941

1942-
pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true },
1942+
pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(),
19431943
set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys),
19441944
channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id,
19451945
provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters,

0 commit comments

Comments
 (0)